diff --git a/apps/minting-service/api/health.ts b/apps/minting-service/handlers/health.ts similarity index 100% rename from apps/minting-service/api/health.ts rename to apps/minting-service/handlers/health.ts diff --git a/apps/minting-service/api/stripe-webhook.ts b/apps/minting-service/handlers/stripe-webhook.ts similarity index 100% rename from apps/minting-service/api/stripe-webhook.ts rename to apps/minting-service/handlers/stripe-webhook.ts diff --git a/apps/minting-service/scripts/build.mjs b/apps/minting-service/scripts/build.mjs index 18ba7d9f5..42db39510 100644 --- a/apps/minting-service/scripts/build.mjs +++ b/apps/minting-service/scripts/build.mjs @@ -2,13 +2,16 @@ /** * Builds the minting-service API functions using Vercel Build Output API v3. * - * - Bundles each `api/*.ts` into a self-contained CommonJS module via esbuild, - * inlining workspace deps (@cacheplane/*) and npm deps alike so no install - * step is required inside each function directory. + * - Bundles each `handlers/*.ts` into a self-contained CommonJS module via + * esbuild, inlining workspace deps (@cacheplane/*) and npm deps alike so no + * install step is required inside each function directory. * - Writes to `.vercel/output/functions/api/.func/` with the companion * `.vc-config.json` Vercel's Node runtime expects. * - Writes `.vercel/output/config.json` at the top level so Vercel picks up - * the Build Output API layout instead of scanning `api/` for TS sources. + * the Build Output API layout instead of scanning the rootDirectory for TS + * sources. The sources live outside `api/` on purpose — Vercel otherwise + * auto-runs @vercel/node on top of our build, which doesn't resolve the + * workspace tsconfig paths and fails the deploy. * * Run via `nx build minting-service`, which sets `cwd` to this app. */ @@ -18,15 +21,15 @@ import { basename, join, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; const appRoot = resolve(fileURLToPath(import.meta.url), '..', '..'); -const apiDir = join(appRoot, 'api'); +const handlersDir = join(appRoot, 'handlers'); const outputRoot = join(appRoot, '.vercel', 'output'); const functionsRoot = join(outputRoot, 'functions', 'api'); async function listEntries() { - const files = await readdir(apiDir); + const files = await readdir(handlersDir); return files .filter((f) => f.endsWith('.ts') && !f.endsWith('.spec.ts') && !f.endsWith('.d.ts')) - .map((f) => join(apiDir, f)); + .map((f) => join(handlersDir, f)); } async function buildEntry(entry) { @@ -74,7 +77,7 @@ async function main() { const entries = await listEntries(); if (entries.length === 0) { - throw new Error(`no api entries found in ${apiDir}`); + throw new Error(`no handler entries found in ${handlersDir}`); } await Promise.all(entries.map(buildEntry)); diff --git a/apps/minting-service/tsconfig.app.json b/apps/minting-service/tsconfig.app.json index 03e3dee32..2a61e4be9 100644 --- a/apps/minting-service/tsconfig.app.json +++ b/apps/minting-service/tsconfig.app.json @@ -10,6 +10,6 @@ "declarationMap": false, "emitDeclarationOnly": false }, - "include": ["src/**/*.ts", "api/**/*.ts", "scripts/**/*.ts"], - "exclude": ["src/**/*.spec.ts", "api/**/*.spec.ts", "scripts/**/*.spec.ts"] + "include": ["src/**/*.ts", "handlers/**/*.ts", "scripts/**/*.ts"], + "exclude": ["src/**/*.spec.ts", "handlers/**/*.spec.ts", "scripts/**/*.spec.ts"] } diff --git a/apps/minting-service/tsconfig.spec.json b/apps/minting-service/tsconfig.spec.json index 003d988f8..29657b91f 100644 --- a/apps/minting-service/tsconfig.spec.json +++ b/apps/minting-service/tsconfig.spec.json @@ -4,5 +4,5 @@ "outDir": "../../dist/out-tsc", "types": ["vitest/globals", "node"] }, - "include": ["src/**/*.spec.ts", "api/**/*.spec.ts", "src/**/*.ts", "api/**/*.ts"] + "include": ["src/**/*.spec.ts", "handlers/**/*.spec.ts", "src/**/*.ts", "handlers/**/*.ts"] } diff --git a/apps/minting-service/vite.config.mts b/apps/minting-service/vite.config.mts index 1acfdde53..5cd72afd1 100644 --- a/apps/minting-service/vite.config.mts +++ b/apps/minting-service/vite.config.mts @@ -6,7 +6,7 @@ export default defineConfig({ test: { environment: 'node', globals: true, - include: ['src/**/*.spec.ts', 'api/**/*.spec.ts', 'scripts/**/*.spec.ts'], + include: ['src/**/*.spec.ts', 'handlers/**/*.spec.ts', 'scripts/**/*.spec.ts'], passWithNoTests: true, }, });