mirror of
https://github.com/stack-auth/stack.git
synced 2026-07-20 21:29:36 +08:00
Simplify Vercel Elysia routing
This commit is contained in:
parent
13d257b905
commit
ef5c6f97e0
@ -1,8 +0,0 @@
|
||||
import app from "../dist/vercel.mjs";
|
||||
|
||||
export const config = {
|
||||
runtime: "nodejs",
|
||||
maxDuration: 800,
|
||||
};
|
||||
|
||||
export default app;
|
||||
@ -1,8 +0,0 @@
|
||||
import app from "../dist/vercel.mjs";
|
||||
|
||||
export const config = {
|
||||
runtime: "nodejs",
|
||||
maxDuration: 60,
|
||||
};
|
||||
|
||||
export default app;
|
||||
@ -1,8 +0,0 @@
|
||||
import app from "../dist/vercel.mjs";
|
||||
|
||||
export const config = {
|
||||
runtime: "nodejs",
|
||||
maxDuration: 120,
|
||||
};
|
||||
|
||||
export default app;
|
||||
4
apps/backend/api/dist-vercel.d.ts
vendored
4
apps/backend/api/dist-vercel.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
declare module "*/dist/vercel.mjs" {
|
||||
const app: typeof import("../src/server/vercel").default;
|
||||
export default app;
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
import app from "../dist/vercel.mjs";
|
||||
|
||||
// Preserve the project-level duration inherited by routes without a pre-Elysia override.
|
||||
export const config = {
|
||||
runtime: "nodejs",
|
||||
};
|
||||
|
||||
export default app;
|
||||
6
apps/backend/src/dist-vercel.d.ts
vendored
Normal file
6
apps/backend/src/dist-vercel.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
declare module "*/dist/vercel.mjs" {
|
||||
import type { Elysia } from "elysia";
|
||||
|
||||
const app: Elysia;
|
||||
export default app;
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
import "@/instrument";
|
||||
import "@/polyfills";
|
||||
import { app } from "./server/app";
|
||||
import "./server/env-expand";
|
||||
// Vercel detects native Elysia entrypoints by a direct framework import.
|
||||
import "elysia";
|
||||
import app from "../dist/vercel.mjs";
|
||||
|
||||
export default app;
|
||||
|
||||
@ -1,39 +1,19 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("Vercel function durations", () => {
|
||||
it("preserves inherited and route-specific limits from the Next.js deployment", async () => {
|
||||
const [vercelJson, defaultEntry, applyEntry, commitEntry, cancelEntry] = await Promise.all([
|
||||
describe("Vercel deployment configuration", () => {
|
||||
it("uses native Elysia routing and inherits the project function duration", async () => {
|
||||
const [vercelJson, entry] = await Promise.all([
|
||||
readFile(new URL("../../vercel.json", import.meta.url), "utf8"),
|
||||
readFile(new URL("../../api/index.ts", import.meta.url), "utf8"),
|
||||
readFile(new URL("../../api/config-github-apply.ts", import.meta.url), "utf8"),
|
||||
readFile(new URL("../../api/config-github-commit.ts", import.meta.url), "utf8"),
|
||||
readFile(new URL("../../api/config-github-cancel.ts", import.meta.url), "utf8"),
|
||||
readFile(new URL("../index.ts", import.meta.url), "utf8"),
|
||||
]);
|
||||
|
||||
expect(JSON.parse(vercelJson)).toMatchObject({
|
||||
rewrites: [
|
||||
{
|
||||
source: "/api/:version/internal/config/github/apply",
|
||||
destination: "/api/config-github-apply",
|
||||
},
|
||||
{
|
||||
source: "/api/:version/internal/config/github/commit",
|
||||
destination: "/api/config-github-commit",
|
||||
},
|
||||
{
|
||||
source: "/api/:version/internal/config/github/cancel",
|
||||
destination: "/api/config-github-cancel",
|
||||
},
|
||||
{
|
||||
source: "/(.*)",
|
||||
destination: "/api",
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(defaultEntry).not.toContain("maxDuration");
|
||||
expect(applyEntry).toContain("maxDuration: 800");
|
||||
expect(commitEntry).toContain("maxDuration: 120");
|
||||
expect(cancelEntry).toContain("maxDuration: 60");
|
||||
const config = JSON.parse(vercelJson);
|
||||
expect(config.framework).toBe("elysia");
|
||||
expect(config).not.toHaveProperty("rewrites");
|
||||
expect(config).not.toHaveProperty("functions");
|
||||
expect(entry).toContain('import "elysia"');
|
||||
expect(entry).toContain('from "../dist/vercel.mjs"');
|
||||
expect(entry).not.toContain("maxDuration");
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,12 +1,6 @@
|
||||
{
|
||||
"$schema": "https://openapi.vercel.sh/vercel.json",
|
||||
"framework": null,
|
||||
"rewrites": [
|
||||
{ "source": "/api/:version/internal/config/github/apply", "destination": "/api/config-github-apply" },
|
||||
{ "source": "/api/:version/internal/config/github/commit", "destination": "/api/config-github-commit" },
|
||||
{ "source": "/api/:version/internal/config/github/cancel", "destination": "/api/config-github-cancel" },
|
||||
{ "source": "/(.*)", "destination": "/api" }
|
||||
],
|
||||
"framework": "elysia",
|
||||
"crons": [
|
||||
{
|
||||
"path": "/api/latest/internal/email-queue-step",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user