Scaffold Vercel serverless serving for Elysia backend

Add a second tsdown entry (src/server/vercel.ts -> dist/vercel.mjs, no-listen handler bundle), a thin api/index.ts Vercel function that re-exports it, and a vercel.json rewrite routing all paths to the function. Needs real-deploy verification (native-dep tracing, rewrite path preservation).
This commit is contained in:
mantrakp04
2026-06-19 13:30:44 -07:00
parent 9830048686
commit 551d1cb38c
3 changed files with 28 additions and 1 deletions
+21
View File
@@ -0,0 +1,21 @@
// Vercel serverless entry for the Elysia backend.
//
// We do NOT bundle the whole backend graph here (the `@/*` and `next/*` alias
// resolution + heavy native deps are handled by tsdown). Instead this thin
// function re-exports the already-built handler bundle (`dist/vercel.mjs`,
// produced by `tsdown` during `turbo build`), and Vercel's function builder
// only has to trace the externalized native deps (prisma, sharp, bcrypt,
// oidc-provider, pg) from node_modules.
//
// All requests are routed here via the `rewrites` rule in vercel.json, so the
// Elysia app does its own routing/version-rewrite against the original URL.
import app from "../dist/vercel.mjs";
export const config = {
runtime: "nodejs",
maxDuration: 60,
};
export default function handler(request: Request): Response | Promise<Response> {
return app.handle(request);
}
+4 -1
View File
@@ -87,7 +87,10 @@ const plugins = [
];
export default defineConfig({
entry: [resolve(backendDir, "src/server/server.ts")],
entry: [
resolve(backendDir, "src/server/server.ts"),
resolve(backendDir, "src/server/vercel.ts"),
],
format: ["esm"],
outDir: resolve(backendDir, "dist"),
target: "node22",
+3
View File
@@ -1,6 +1,9 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"framework": null,
"rewrites": [
{ "source": "/(.*)", "destination": "/api" }
],
"crons": [
{
"path": "/api/latest/internal/email-queue-step",