Skip to content

fix(example): move express-basic-auth function to api/ directory - #308

Merged
amondnet merged 3 commits into
masterfrom
amondnet/reinvented-mask
Mar 26, 2026
Merged

fix(example): move express-basic-auth function to api/ directory#308
amondnet merged 3 commits into
masterfrom
amondnet/reinvented-mask

Conversation

@amondnet

@amondnet amondnet commented Mar 26, 2026

Copy link
Copy Markdown
Owner
  • Analyze PR review comments (comment_id: 2992526128 - already confirmed applied in commit 253fbdb)
  • Investigate CI failures:
    • ESLint failure: .github/dependabot.yml YAML style (pre-existing on master)
    • check-dist failure: master updated package.json to node 24.x but dist/ was built with 22.x
    • Fix check-dist: updated root package.json to node 24.x and rebuilt dist/
    • Note: basic-auth deployment uses pull_request_target (runs base branch code) - will pass after merge
    • Note: ESLint .github/dependabot.yml issue is from master branch (pre-existing)

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Copilot AI review requested due to automatic review settings March 26, 2026 05:08
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical deployment issue for the express-basic-auth example when using Vercel CLI v41+. It reconfigures the project structure by relocating the main serverless function into the Vercel-mandated api/ directory and updates the associated Vercel configuration to ensure proper function discovery and routing. This ensures the example remains deployable and fully functional on the latest Vercel platform.

Highlights

  • File Restructuring: The express-basic-auth serverless function was moved from example/express-basic-auth/index.js to example/express-basic-auth/api/index.js to comply with Vercel CLI v41+ requirements.
  • Vercel Configuration Update: The vercel.ts configuration was updated to reflect the new function path and adjust the includeFiles pattern and rewrite destination accordingly.
  • Deployment Fix: This change resolves a deployment error where Vercel CLI v41+ could not find the serverless function due to an incorrect directory structure.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions

github-actions Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Deploy preview for team-scope-test ready!

✅ Preview
https://team-scope-test-eizdcuegx-dietfriends.vercel.app

Built with commit e938762.
This pull request is being automatically deployed with vercel-action

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Auto-approved: Updates example structure to comply with Vercel CLI v41+ requirements; low risk as it only affects an example directory.

Architecture diagram
sequenceDiagram
    participant Client as Client Browser
    participant Router as Vercel Edge Router
    participant App as Serverless Function (Express)
    participant Storage as File System (_static/)

    Note over Router,App: Vercel CLI v41+ Routing Flow

    Client->>Router: GET /path
    Router->>Router: CHANGED: Apply rewrite to /api/index.js
    Router->>App: Invoke Serverless Function
    
    Note over App: Basic Auth Middleware
    
    alt Auth Success
        App->>Storage: CHANGED: Resolve static assets via ../_static
        Storage-->>App: File data
        App-->>Client: 200 OK (Static content)
    else Auth Failure
        App-->>Client: 401 Unauthorized (WWW-Authenticate)
    end
Loading

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the express-basic-auth example by moving the main index.js file into an api subdirectory and adjusting the path to the static assets directory (_static) to be one level up from the new api directory. The vercel.ts configuration has been updated to reflect these changes, correctly pointing to the new function entry point at /api/index.js and including static files from ../_static/**. There are no review comments to address.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the example/express-basic-auth deployment configuration and code layout to satisfy Vercel CLI v41+ expectations that Serverless Functions live under the api/ directory.

Changes:

  • Update functions and rewrites in the example’s Vercel config to reference api/index.js.
  • Adjust Express static asset path to account for the function now living under api/.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
example/express-basic-auth/vercel.ts Points function config and rewrites at api/index.js, updates bundled static files glob.
example/express-basic-auth/api/index.js Updates static directory resolution for the new directory structure.
Comments suppressed due to low confidence (1)

example/express-basic-auth/api/index.js:16

  • This file is now under api/, so it will be deployed as a Vercel Serverless Function. In that runtime, calling app.listen(...) is generally incorrect (it can hang the invocation), and nothing is exported for the platform to invoke. Consider exporting the Express app/handler (e.g., module.exports = app) and guarding app.listen so it only runs when executed directly for local development.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread example/express-basic-auth/vercel.ts Outdated
'index.js': {
includeFiles: '_static/**/*.js',
'api/index.js': {
includeFiles: '../_static/**',

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

includeFiles is set to ../_static/**, but Vercel function config patterns appear to be evaluated relative to the project root (same as the functions key path). Using .. likely won’t match the intended _static folder and can cause missing static assets at runtime. Consider changing this to _static/** (or another root-relative glob that matches the folder you want bundled).

Suggested change
includeFiles: '../_static/**',
includeFiles: '_static/**',

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Applied in 253fbdb

  • File: example/express-basic-auth/vercel.ts
  • Change: Updated includeFiles from '../_static/**' to '_static/**' (root-relative glob matching Vercel's project-root evaluation)

Thanks for the suggestion, @copilot-pull-request-reviewer!

Comment thread example/express-basic-auth/vercel.ts Outdated
Comment on lines +7 to +8
'api/index.js': {
includeFiles: '../_static/**',

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After moving the entrypoint into api/index.js, the example package metadata still points at index.js (e.g., package.json#main). This will break local usage like node ./require() and is confusing for the example. Consider updating the example’s package.json to reference the new entrypoint (or add a small root index.js that forwards to api/index.js).

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Applied in 253fbdb

  • File: example/express-basic-auth/package.json
  • Change: Updated main from 'index.js' to 'api/index.js' to match the moved entrypoint

Thanks for the suggestion, @copilot-pull-request-reviewer!

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Auto-approved: This is a safe configuration and directory structure update for a specific example to comply with Vercel CLI requirements. Low risk and isolated to example code.

Vercel CLI v41+ requires serverless functions to be inside the `api/`
directory. The `functions` config referencing `index.js` at the project
root no longer works, causing deployment error:
"The pattern 'index.js' defined in functions doesn't match any
Serverless Functions inside the api directory."

- Move index.js to api/index.js
- Update functions pattern and rewrites destination in vercel.ts
- Update includeFiles and static path for new directory structure
…-basic-auth

- Change includeFiles from '../_static/**' to '_static/**' (root-relative)
- Update package.json#main from 'index.js' to 'api/index.js' to reflect moved entrypoint
Align all CI workflows, .nvmrc, and check-dist with the node24
runtime update in action.yml and package.json engines (24.x).
Rebuild dist/ with Node 24 to match.
@amondnet
amondnet force-pushed the amondnet/reinvented-mask branch from c4e71a3 to e938762 Compare March 26, 2026 05:40
@amondnet
amondnet merged commit 1c7fbdd into master Mar 26, 2026
6 of 13 checks passed
@amondnet
amondnet deleted the amondnet/reinvented-mask branch March 26, 2026 05:41
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 3 files (changes from recent commits).

Requires human review: Changes to CI/CD workflows (Node.js version bump) and deployment configuration (vercel.ts) for the example project require human review.

amondnet added a commit that referenced this pull request Mar 26, 2026
* fix(example): move express-basic-auth function to api/ directory

Vercel CLI v41+ requires serverless functions to be inside the `api/`
directory. The `functions` config referencing `index.js` at the project
root no longer works, causing deployment error:
"The pattern 'index.js' defined in functions doesn't match any
Serverless Functions inside the api directory."

- Move index.js to api/index.js
- Update functions pattern and rewrites destination in vercel.ts
- Update includeFiles and static path for new directory structure

* fix(example): fix includeFiles path and package.json main for express-basic-auth

- Change includeFiles from '../_static/**' to '_static/**' (root-relative)
- Update package.json#main from 'index.js' to 'api/index.js' to reflect moved entrypoint

* ci: update workflow node version and .nvmrc to 24

Align all CI workflows, .nvmrc, and check-dist with the node24
runtime update in action.yml and package.json engines (24.x).
Rebuild dist/ with Node 24 to match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants