Skip to content

Commit 781e4b4

Browse files
bloveclaude
andcommitted
fix(minting-service): move handler sources out of api/ for Vercel deploy
The Nx esbuild build (PR #133) produced a correct Build Output API v3 layout under `.vercel/output/functions/api/*.func/`, but Vercel's default Node builder still auto-detects `api/*.ts` at the project root and runs `@vercel/node` on top of our output. That failed with `api/health.ts: Emit skipped` because @vercel/node's tsc doesn't resolve the workspace tsconfig paths. Rename `apps/minting-service/api/` → `apps/minting-service/handlers/` so Vercel's auto-detection finds nothing and falls back to the Build Output API our buildCommand already produces. The deployed URL path (`/api/health`, `/api/stripe-webhook`) is unchanged — esbuild still emits to `.vercel/output/functions/api/<name>.func/`. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
1 parent fc73d3e commit 781e4b4

6 files changed

Lines changed: 15 additions & 12 deletions

File tree

File renamed without changes.

apps/minting-service/scripts/build.mjs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
/**
33
* Builds the minting-service API functions using Vercel Build Output API v3.
44
*
5-
* - Bundles each `api/*.ts` into a self-contained CommonJS module via esbuild,
6-
* inlining workspace deps (@cacheplane/*) and npm deps alike so no install
7-
* step is required inside each function directory.
5+
* - Bundles each `handlers/*.ts` into a self-contained CommonJS module via
6+
* esbuild, inlining workspace deps (@cacheplane/*) and npm deps alike so no
7+
* install step is required inside each function directory.
88
* - Writes to `.vercel/output/functions/api/<name>.func/` with the companion
99
* `.vc-config.json` Vercel's Node runtime expects.
1010
* - Writes `.vercel/output/config.json` at the top level so Vercel picks up
11-
* the Build Output API layout instead of scanning `api/` for TS sources.
11+
* the Build Output API layout instead of scanning the rootDirectory for TS
12+
* sources. The sources live outside `api/` on purpose — Vercel otherwise
13+
* auto-runs @vercel/node on top of our build, which doesn't resolve the
14+
* workspace tsconfig paths and fails the deploy.
1215
*
1316
* Run via `nx build minting-service`, which sets `cwd` to this app.
1417
*/
@@ -18,15 +21,15 @@ import { basename, join, resolve } from 'node:path';
1821
import { fileURLToPath } from 'node:url';
1922

2023
const appRoot = resolve(fileURLToPath(import.meta.url), '..', '..');
21-
const apiDir = join(appRoot, 'api');
24+
const handlersDir = join(appRoot, 'handlers');
2225
const outputRoot = join(appRoot, '.vercel', 'output');
2326
const functionsRoot = join(outputRoot, 'functions', 'api');
2427

2528
async function listEntries() {
26-
const files = await readdir(apiDir);
29+
const files = await readdir(handlersDir);
2730
return files
2831
.filter((f) => f.endsWith('.ts') && !f.endsWith('.spec.ts') && !f.endsWith('.d.ts'))
29-
.map((f) => join(apiDir, f));
32+
.map((f) => join(handlersDir, f));
3033
}
3134

3235
async function buildEntry(entry) {
@@ -74,7 +77,7 @@ async function main() {
7477

7578
const entries = await listEntries();
7679
if (entries.length === 0) {
77-
throw new Error(`no api entries found in ${apiDir}`);
80+
throw new Error(`no handler entries found in ${handlersDir}`);
7881
}
7982

8083
await Promise.all(entries.map(buildEntry));

apps/minting-service/tsconfig.app.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"declarationMap": false,
1111
"emitDeclarationOnly": false
1212
},
13-
"include": ["src/**/*.ts", "api/**/*.ts", "scripts/**/*.ts"],
14-
"exclude": ["src/**/*.spec.ts", "api/**/*.spec.ts", "scripts/**/*.spec.ts"]
13+
"include": ["src/**/*.ts", "handlers/**/*.ts", "scripts/**/*.ts"],
14+
"exclude": ["src/**/*.spec.ts", "handlers/**/*.spec.ts", "scripts/**/*.spec.ts"]
1515
}

apps/minting-service/tsconfig.spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"outDir": "../../dist/out-tsc",
55
"types": ["vitest/globals", "node"]
66
},
7-
"include": ["src/**/*.spec.ts", "api/**/*.spec.ts", "src/**/*.ts", "api/**/*.ts"]
7+
"include": ["src/**/*.spec.ts", "handlers/**/*.spec.ts", "src/**/*.ts", "handlers/**/*.ts"]
88
}

apps/minting-service/vite.config.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
test: {
77
environment: 'node',
88
globals: true,
9-
include: ['src/**/*.spec.ts', 'api/**/*.spec.ts', 'scripts/**/*.spec.ts'],
9+
include: ['src/**/*.spec.ts', 'handlers/**/*.spec.ts', 'scripts/**/*.spec.ts'],
1010
passWithNoTests: true,
1111
},
1212
});

0 commit comments

Comments
 (0)