@catmint/adapter-vercel 0.0.0-prealpha.1 → 0.0.0-prealpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/dist/config-gen.d.ts +3 -0
- package/dist/config-gen.d.ts.map +1 -1
- package/dist/config-gen.js +35 -2
- package/dist/config-gen.js.map +1 -1
- package/dist/function-gen.d.ts +1 -1
- package/dist/function-gen.d.ts.map +1 -1
- package/dist/function-gen.js +297 -29
- package/dist/function-gen.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +74 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @catmint/adapter-vercel
|
|
2
|
+
|
|
3
|
+
Vercel deployment adapter for [Catmint](https://github.com/darylcecile/catmint).
|
|
4
|
+
|
|
5
|
+
Generates output in the [Vercel Build Output API v3](https://vercel.com/docs/build-output-api/v3) format, including serverless functions, static assets, and prerender functions for cached routes.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @catmint/adapter-vercel
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// catmint.config.ts
|
|
17
|
+
import { defineConfig } from "catmint/config";
|
|
18
|
+
import vercelAdapter from "@catmint/adapter-vercel";
|
|
19
|
+
|
|
20
|
+
export default defineConfig({
|
|
21
|
+
mode: "fullstack",
|
|
22
|
+
adapter: vercelAdapter({
|
|
23
|
+
runtime: "nodejs",
|
|
24
|
+
regions: ["iad1"],
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Options
|
|
30
|
+
|
|
31
|
+
| Option | Type | Default | Description |
|
|
32
|
+
| --------- | ---------------------- | ---------- | --------------------------- |
|
|
33
|
+
| `runtime` | `"nodejs"` \| `"edge"` | `"nodejs"` | Serverless function runtime |
|
|
34
|
+
| `regions` | `string[]` | -- | Deployment regions |
|
|
35
|
+
|
|
36
|
+
## Deploy
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
catmint build
|
|
40
|
+
vercel deploy --prebuilt
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
GNU General Public License v2
|
package/dist/config-gen.d.ts
CHANGED
package/dist/config-gen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-gen.d.ts","sourceRoot":"","sources":["../src/config-gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,UAAU,iBAAiB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,KAAK,CAAC;QACV,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;QAC7C,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,UAAU,kBAAkB;IAC1B,MAAM,EAAE,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;IACzE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,KAAK,WAAW,GAAG,i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;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,WAAW,GAAG,YAAY,CA6GxE"}
|
package/dist/config-gen.js
CHANGED
|
@@ -40,7 +40,11 @@ export function generateVercelConfig(manifest) {
|
|
|
40
40
|
dest: "/index",
|
|
41
41
|
});
|
|
42
42
|
// 3. Process manifest routes
|
|
43
|
+
// Skip static routes without middleware — they are served directly from
|
|
44
|
+
// the static/ directory via { handle: "filesystem" } below.
|
|
43
45
|
for (const route of [...manifest.routes, ...manifest.endpoints]) {
|
|
46
|
+
if (route.renderMode === "static" && !route.hasMiddleware)
|
|
47
|
+
continue;
|
|
44
48
|
const src = routePathToVercelSrc(route.path);
|
|
45
49
|
// For cached routes with prerender configs, route to the dedicated function
|
|
46
50
|
const routeName = route.cache && route.path !== "/"
|
|
@@ -69,11 +73,25 @@ export function generateVercelConfig(manifest) {
|
|
|
69
73
|
}
|
|
70
74
|
routes.push(vercelRoute);
|
|
71
75
|
}
|
|
72
|
-
// 4.
|
|
76
|
+
// 4. Rewrite middleware-protected static routes to the serverless function.
|
|
77
|
+
// These paths have pre-rendered HTML but must go through middleware, so
|
|
78
|
+
// they MUST NOT be served from the static/ directory by Vercel's CDN.
|
|
79
|
+
// This rewrite rule runs BEFORE { handle: "filesystem" } to intercept
|
|
80
|
+
// the request before Vercel checks for a matching static file.
|
|
81
|
+
for (const route of manifest.routes) {
|
|
82
|
+
if (route.hasMiddleware && route.renderMode === "static") {
|
|
83
|
+
const src = routePathToVercelSrc(route.path);
|
|
84
|
+
routes.push({
|
|
85
|
+
src,
|
|
86
|
+
dest: "/index",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// 5. Check the filesystem (static/ directory) before the catch-all.
|
|
73
91
|
// Without this, the catch-all below would intercept requests for static
|
|
74
92
|
// assets (JS, CSS, images) and send them to the serverless function.
|
|
75
93
|
routes.push({ handle: "filesystem" });
|
|
76
|
-
//
|
|
94
|
+
// 6. Fallback: rewrite all unmatched requests to the serverless function
|
|
77
95
|
// This only triggers for requests that didn't match a static file above.
|
|
78
96
|
if (manifest.mode !== "frontend") {
|
|
79
97
|
routes.push({
|
|
@@ -81,9 +99,24 @@ export function generateVercelConfig(manifest) {
|
|
|
81
99
|
dest: "/index",
|
|
82
100
|
});
|
|
83
101
|
}
|
|
102
|
+
// 7. Build overrides map for static routes.
|
|
103
|
+
// Pre-rendered HTML is written as e.g. "about.html" but the browser
|
|
104
|
+
// requests "/about" (clean URL). Vercel's filesystem handler does an
|
|
105
|
+
// exact path match, so without overrides it won't find the .html file
|
|
106
|
+
// and the request falls through to the catch-all serverless function.
|
|
107
|
+
// The overrides map tells Vercel to serve "about.html" for path "about".
|
|
108
|
+
const overrides = {};
|
|
109
|
+
for (const route of manifest.routes) {
|
|
110
|
+
if (route.renderMode === "static" && !route.hasMiddleware) {
|
|
111
|
+
const cleanPath = route.path === "/" ? "index" : route.path.replace(/^\//, "");
|
|
112
|
+
const htmlFile = cleanPath + ".html";
|
|
113
|
+
overrides[htmlFile] = { path: cleanPath };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
84
116
|
return {
|
|
85
117
|
version: 3,
|
|
86
118
|
routes,
|
|
119
|
+
...(Object.keys(overrides).length > 0 ? { overrides } : {}),
|
|
87
120
|
};
|
|
88
121
|
}
|
|
89
122
|
//# sourceMappingURL=config-gen.js.map
|
package/dist/config-gen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-gen.js","sourceRoot":"","sources":["../src/config-gen.ts"],"names":[],"mappings":"AAAA,0EAA0E;
|
|
1
|
+
{"version":3,"file":"config-gen.js","sourceRoot":"","sources":["../src/config-gen.ts"],"names":[],"mappings":"AAAA,0EAA0E;AA4C1E;;;;;;;;GAQG;AACH,SAAS,oBAAoB,CAAC,SAAiB;IAC7C,OAAO,SAAS;SACb,OAAO,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC,0BAA0B;SAC9D,OAAO,CAAC,WAAW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AAE,YAAY,EAAE,CAAC,CAAC;IAEtC,yEAAyE;IACzE,yEAAyE;IACzE,IAAI,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC;YACV,GAAG,EAAE,OAAO;YACZ,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IAED,4CAA4C;IAC5C,oEAAoE;IACpE,qEAAqE;IACrE,sEAAsE;IACtE,sEAAsE;IACtE,yEAAyE;IACzE,MAAM,SAAS,GAAqC,EAAE,CAAC;IACvD,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpC,IAAI,KAAK,CAAC,UAAU,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;YAC1D,MAAM,SAAS,GACb,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC/D,MAAM,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;YACrC,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,CAAC;QACV,MAAM;QACN,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5D,CAAC;AACJ,CAAC"}
|
package/dist/function-gen.d.ts
CHANGED
|
@@ -36,6 +36,6 @@ export declare function generateVcConfig(runtime: "nodejs" | "edge", regions?: s
|
|
|
36
36
|
* function registers a platform cache adapter that delegates invalidation
|
|
37
37
|
* to Vercel's on-demand ISR revalidation API.
|
|
38
38
|
*/
|
|
39
|
-
export declare function generateServerlessFunction(manifest: AppManifest, runtime: "nodejs" | "edge"): string;
|
|
39
|
+
export declare function generateServerlessFunction(manifest: AppManifest, runtime: "nodejs" | "edge", maxBodySize: number, headerPreset: "baseline" | "none"): string;
|
|
40
40
|
export {};
|
|
41
41
|
//# sourceMappingURL=function-gen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-gen.d.ts","sourceRoot":"","sources":["../src/function-gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,QAAQ,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,KAAK,QAAQ,GAAG,cAAc,GAAG,YAAY,CAAC;AAmF9C;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,QAAQ,GAAG,MAAM,EAC1B,OAAO,CAAC,EAAE,MAAM,EAAE,GACjB,QAAQ,CAqBV;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,QAAQ,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"function-gen.d.ts","sourceRoot":"","sources":["../src/function-gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,QAAQ,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,KAAK,QAAQ,GAAG,cAAc,GAAG,YAAY,CAAC;AAmF9C;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,QAAQ,GAAG,MAAM,EAC1B,OAAO,CAAC,EAAE,MAAM,EAAE,GACjB,QAAQ,CAqBV;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,QAAQ,GAAG,MAAM,EAC1B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,UAAU,GAAG,MAAM,GAChC,MAAM,CAKR"}
|
package/dist/function-gen.js
CHANGED
|
@@ -112,27 +112,65 @@ export function generateVcConfig(runtime, regions) {
|
|
|
112
112
|
* function registers a platform cache adapter that delegates invalidation
|
|
113
113
|
* to Vercel's on-demand ISR revalidation API.
|
|
114
114
|
*/
|
|
115
|
-
export function generateServerlessFunction(manifest, runtime) {
|
|
115
|
+
export function generateServerlessFunction(manifest, runtime, maxBodySize, headerPreset) {
|
|
116
116
|
if (runtime === "edge") {
|
|
117
|
-
return generateEdgeFunction(manifest);
|
|
117
|
+
return generateEdgeFunction(manifest, maxBodySize, headerPreset);
|
|
118
118
|
}
|
|
119
|
-
return generateNodejsFunction(manifest);
|
|
119
|
+
return generateNodejsFunction(manifest, maxBodySize, headerPreset);
|
|
120
120
|
}
|
|
121
|
-
function generateNodejsFunction(manifest) {
|
|
121
|
+
function generateNodejsFunction(manifest, maxBodySize, headerPreset) {
|
|
122
122
|
const cacheAdapterSetup = generateCacheAdapterSetup(manifest);
|
|
123
123
|
return `// Auto-generated by @catmint/adapter-vercel (Node.js runtime) — do not edit
|
|
124
124
|
import * as rscEntry from "./rsc/index.js";
|
|
125
125
|
import * as ssrEntry from "./ssr/index.js";
|
|
126
|
+
import { readFile, stat } from "node:fs/promises";
|
|
127
|
+
import { join, extname } from "node:path";
|
|
128
|
+
import { fileURLToPath } from "node:url";
|
|
129
|
+
|
|
130
|
+
const __dirname = fileURLToPath(new URL(".", import.meta.url));
|
|
131
|
+
const PRERENDERED_DIR = join(__dirname, "prerendered");
|
|
126
132
|
${cacheAdapterSetup}
|
|
127
133
|
function collectBody(req) {
|
|
134
|
+
const MAX_BODY_SIZE = ${maxBodySize};
|
|
128
135
|
return new Promise((resolve, reject) => {
|
|
129
136
|
const chunks = [];
|
|
130
|
-
|
|
137
|
+
let totalLength = 0;
|
|
138
|
+
req.on("data", (chunk) => {
|
|
139
|
+
totalLength += chunk.length;
|
|
140
|
+
if (totalLength > MAX_BODY_SIZE) {
|
|
141
|
+
req.destroy();
|
|
142
|
+
reject(new Error("Request body too large"));
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
chunks.push(chunk);
|
|
146
|
+
});
|
|
131
147
|
req.on("end", () => resolve(Buffer.concat(chunks)));
|
|
132
148
|
req.on("error", reject);
|
|
133
149
|
});
|
|
134
150
|
}
|
|
135
151
|
|
|
152
|
+
function nodeReqToWebRequest(req) {
|
|
153
|
+
const protocol = "https";
|
|
154
|
+
const host = req.headers.host || "localhost";
|
|
155
|
+
const reqUrl = new URL(req.url || "/", \`\${protocol}://\${host}\`);
|
|
156
|
+
const headers = new Headers();
|
|
157
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
158
|
+
if (value) {
|
|
159
|
+
if (Array.isArray(value)) {
|
|
160
|
+
for (const v of value) {
|
|
161
|
+
headers.append(key, v);
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
headers.set(key, value);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return new Request(reqUrl.href, {
|
|
169
|
+
method: req.method || "GET",
|
|
170
|
+
headers,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
136
174
|
async function pipeWebStreamToResponse(webStream, res) {
|
|
137
175
|
const reader = webStream.getReader();
|
|
138
176
|
try {
|
|
@@ -216,13 +254,97 @@ function __catmintErrorPage(statusCode, detail) {
|
|
|
216
254
|
}
|
|
217
255
|
|
|
218
256
|
export default async function handler(req, res) {
|
|
257
|
+
${headerPreset === "baseline"
|
|
258
|
+
? ` // Baseline security headers
|
|
259
|
+
res.setHeader("X-Content-Type-Options", "nosniff");
|
|
260
|
+
res.setHeader("Referrer-Policy", "strict-origin-when-cross-origin");
|
|
261
|
+
res.setHeader("X-Frame-Options", "SAMEORIGIN");
|
|
262
|
+
`
|
|
263
|
+
: ""}
|
|
219
264
|
const url = new URL(req.url || "/", \`https://\${req.headers.host || "localhost"}\`);
|
|
220
265
|
const pathname = url.pathname;
|
|
221
266
|
const method = (req.method || "GET").toUpperCase();
|
|
222
267
|
|
|
223
268
|
try {
|
|
224
|
-
// 1.
|
|
269
|
+
// 1. Middleware execution — runs for all routes handled by this function.
|
|
270
|
+
// For RSC flight requests, run middleware against the TARGET page path
|
|
271
|
+
// (from ?path= query param), not the literal /__catmint/rsc pathname.
|
|
272
|
+
var middlewareHeaders = null;
|
|
273
|
+
if (ssrEntry.executeMiddleware) {
|
|
274
|
+
try {
|
|
275
|
+
var middlewarePath = pathname;
|
|
276
|
+
if (pathname === "/__catmint/rsc") {
|
|
277
|
+
var rscTargetPath = url.searchParams.get("path");
|
|
278
|
+
if (rscTargetPath) middlewarePath = rscTargetPath;
|
|
279
|
+
}
|
|
280
|
+
var webRequest = nodeReqToWebRequest(req);
|
|
281
|
+
var mwResult = await ssrEntry.executeMiddleware(middlewarePath, webRequest);
|
|
282
|
+
|
|
283
|
+
if (mwResult.shortCircuit) {
|
|
284
|
+
// Middleware short-circuited — return its response directly
|
|
285
|
+
res.statusCode = mwResult.shortCircuit.status;
|
|
286
|
+
mwResult.shortCircuit.headers.forEach(function(value, key) {
|
|
287
|
+
res.setHeader(key, value);
|
|
288
|
+
});
|
|
289
|
+
var scBody = await mwResult.shortCircuit.text();
|
|
290
|
+
res.end(scBody);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Middleware passed — capture headers to merge into final response
|
|
295
|
+
if (mwResult.headers && typeof mwResult.headers.forEach === "function") {
|
|
296
|
+
middlewareHeaders = mwResult.headers;
|
|
297
|
+
}
|
|
298
|
+
} catch (err) {
|
|
299
|
+
console.error("Middleware error:", err);
|
|
300
|
+
if (!res.headersSent) {
|
|
301
|
+
res.statusCode = 500;
|
|
302
|
+
res.end("Internal Server Error");
|
|
303
|
+
}
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Helper: merge middleware headers into the response before sending.
|
|
309
|
+
function applyMiddlewareHeaders() {
|
|
310
|
+
if (middlewareHeaders) {
|
|
311
|
+
middlewareHeaders.forEach(function(value, key) {
|
|
312
|
+
res.setHeader(key, value);
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// 2. Handle server function RPC calls (/__catmint/fn/*)
|
|
225
318
|
if (pathname.startsWith("/__catmint/fn/") && ssrEntry.handleServerFn) {
|
|
319
|
+
// Enforce POST method
|
|
320
|
+
if (method !== "POST") {
|
|
321
|
+
res.statusCode = 405;
|
|
322
|
+
res.setHeader("Content-Type", "application/json");
|
|
323
|
+
res.end(JSON.stringify({ error: "Method " + method + " not allowed, expected POST" }));
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Enforce Content-Type: application/json
|
|
328
|
+
const ct = (req.headers["content-type"] || "").toLowerCase();
|
|
329
|
+
if (ct && !ct.startsWith("application/json")) {
|
|
330
|
+
res.statusCode = 415;
|
|
331
|
+
res.setHeader("Content-Type", "application/json");
|
|
332
|
+
res.end(JSON.stringify({ error: "Unsupported Content-Type, expected application/json" }));
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Validate Origin header
|
|
337
|
+
const origin = req.headers["origin"];
|
|
338
|
+
if (origin) {
|
|
339
|
+
const expectedHost = req.headers.host || "localhost";
|
|
340
|
+
if (origin !== \`https://\${expectedHost}\` && origin !== \`http://\${expectedHost}\`) {
|
|
341
|
+
res.statusCode = 403;
|
|
342
|
+
res.setHeader("Content-Type", "application/json");
|
|
343
|
+
res.end(JSON.stringify({ error: "Origin not allowed" }));
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
226
348
|
const body = await collectBody(req);
|
|
227
349
|
let parsed;
|
|
228
350
|
try {
|
|
@@ -235,6 +357,7 @@ export default async function handler(req, res) {
|
|
|
235
357
|
}
|
|
236
358
|
const result = await ssrEntry.handleServerFn(pathname, parsed);
|
|
237
359
|
if (result) {
|
|
360
|
+
applyMiddlewareHeaders();
|
|
238
361
|
res.statusCode = 200;
|
|
239
362
|
res.setHeader("Content-Type", "application/json");
|
|
240
363
|
res.end(JSON.stringify(result.result));
|
|
@@ -246,7 +369,7 @@ export default async function handler(req, res) {
|
|
|
246
369
|
return;
|
|
247
370
|
}
|
|
248
371
|
|
|
249
|
-
//
|
|
372
|
+
// 3. RSC flight stream for client-side navigation (/__catmint/rsc?path=...)
|
|
250
373
|
if (pathname === "/__catmint/rsc" && method === "GET" && rscEntry.render) {
|
|
251
374
|
const targetPath = url.searchParams.get("path");
|
|
252
375
|
if (!targetPath) {
|
|
@@ -258,6 +381,7 @@ export default async function handler(req, res) {
|
|
|
258
381
|
try {
|
|
259
382
|
const rscResult = await rscEntry.render(targetPath);
|
|
260
383
|
if (rscResult) {
|
|
384
|
+
applyMiddlewareHeaders();
|
|
261
385
|
res.statusCode = 200;
|
|
262
386
|
res.setHeader("Content-Type", "text/x-component; charset=utf-8");
|
|
263
387
|
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
|
@@ -278,7 +402,7 @@ export default async function handler(req, res) {
|
|
|
278
402
|
return;
|
|
279
403
|
}
|
|
280
404
|
|
|
281
|
-
//
|
|
405
|
+
// 4. API endpoint handling
|
|
282
406
|
if (ssrEntry.hasEndpoint && ssrEntry.hasEndpoint(pathname)) {
|
|
283
407
|
const fullUrl = \`https://\${req.headers.host || "localhost"}\${req.url || "/"}\`;
|
|
284
408
|
const requestInit = {
|
|
@@ -300,6 +424,7 @@ export default async function handler(req, res) {
|
|
|
300
424
|
result.response.headers.forEach((value, key) => {
|
|
301
425
|
res.setHeader(key, value);
|
|
302
426
|
});
|
|
427
|
+
applyMiddlewareHeaders();
|
|
303
428
|
res.statusCode = result.response.status;
|
|
304
429
|
if (result.response.body) {
|
|
305
430
|
await pipeWebStreamToResponse(result.response.body, res);
|
|
@@ -315,11 +440,41 @@ export default async function handler(req, res) {
|
|
|
315
440
|
return;
|
|
316
441
|
}
|
|
317
442
|
|
|
318
|
-
//
|
|
443
|
+
// 5. Pre-rendered pages WITH middleware: serve from function bundle.
|
|
444
|
+
// These are static routes that have middleware ancestors — their HTML
|
|
445
|
+
// was pre-rendered but placed in the function directory, not in
|
|
446
|
+
// Vercel's static/ directory (to avoid bypassing middleware).
|
|
447
|
+
if (method === "GET") {
|
|
448
|
+
let prerenderedPath = pathname;
|
|
449
|
+
if (!extname(prerenderedPath)) {
|
|
450
|
+
prerenderedPath = prerenderedPath.endsWith("/")
|
|
451
|
+
? prerenderedPath + "index.html"
|
|
452
|
+
: prerenderedPath + ".html";
|
|
453
|
+
}
|
|
454
|
+
try {
|
|
455
|
+
const prFilePath = join(PRERENDERED_DIR, prerenderedPath);
|
|
456
|
+
const prStats = await stat(prFilePath);
|
|
457
|
+
if (prStats.isFile()) {
|
|
458
|
+
const content = await readFile(prFilePath);
|
|
459
|
+
applyMiddlewareHeaders();
|
|
460
|
+
res.statusCode = 200;
|
|
461
|
+
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
462
|
+
res.setHeader("Content-Length", content.byteLength);
|
|
463
|
+
res.setHeader("Cache-Control", "public, max-age=0, must-revalidate");
|
|
464
|
+
res.end(content);
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
} catch {
|
|
468
|
+
// No prerendered file — continue to RSC rendering
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// 6. RSC → SSR page rendering pipeline
|
|
319
473
|
if (method === "GET" && rscEntry.render) {
|
|
320
474
|
const rscResult = await rscEntry.render(pathname);
|
|
321
475
|
if (rscResult) {
|
|
322
476
|
const htmlStream = await ssrEntry.renderToHtml(rscResult.stream, rscResult.headConfig);
|
|
477
|
+
applyMiddlewareHeaders();
|
|
323
478
|
res.statusCode = 200;
|
|
324
479
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
325
480
|
await pipeWebStreamToResponse(htmlStream, res);
|
|
@@ -327,7 +482,7 @@ export default async function handler(req, res) {
|
|
|
327
482
|
}
|
|
328
483
|
}
|
|
329
484
|
|
|
330
|
-
//
|
|
485
|
+
// 7. Fallback 404
|
|
331
486
|
await sendStatusPage(res, 404, pathname);
|
|
332
487
|
} catch (err) {
|
|
333
488
|
console.error("Serverless function error:", err);
|
|
@@ -336,11 +491,14 @@ export default async function handler(req, res) {
|
|
|
336
491
|
}
|
|
337
492
|
`;
|
|
338
493
|
}
|
|
339
|
-
function generateEdgeFunction(manifest) {
|
|
494
|
+
function generateEdgeFunction(manifest, maxBodySize, headerPreset) {
|
|
340
495
|
const cacheAdapterSetup = generateCacheAdapterSetup(manifest);
|
|
496
|
+
// Check if there are middleware-protected static routes
|
|
497
|
+
const hasMiddlewareProtected = manifest.routes.some((r) => r.hasMiddleware && r.renderMode === "static");
|
|
341
498
|
return `// Auto-generated by @catmint/adapter-vercel (Edge runtime) — do not edit
|
|
342
499
|
import * as rscEntry from "./rsc/index.js";
|
|
343
500
|
import * as ssrEntry from "./ssr/index.js";
|
|
501
|
+
${hasMiddlewareProtected ? 'import { prerenderedPages } from "./prerendered.js";' : ""}
|
|
344
502
|
${cacheAdapterSetup}
|
|
345
503
|
async function statusPageResponse(statusCode, pathname) {
|
|
346
504
|
if (rscEntry.renderStatusPage && ssrEntry.renderToHtml) {
|
|
@@ -407,37 +565,133 @@ export default async function handler(request) {
|
|
|
407
565
|
const pathname = url.pathname;
|
|
408
566
|
const method = request.method.toUpperCase();
|
|
409
567
|
|
|
568
|
+
// Helper to create responses${headerPreset === "baseline" ? " with baseline security headers" : ""}
|
|
569
|
+
function secureResponse(body, init = {}) {
|
|
570
|
+
const headers = new Headers(init.headers || {});
|
|
571
|
+
${headerPreset === "baseline"
|
|
572
|
+
? ` headers.set("X-Content-Type-Options", "nosniff");
|
|
573
|
+
headers.set("Referrer-Policy", "strict-origin-when-cross-origin");
|
|
574
|
+
headers.set("X-Frame-Options", "SAMEORIGIN");
|
|
575
|
+
`
|
|
576
|
+
: ""} return new Response(body, { ...init, headers });
|
|
577
|
+
}
|
|
578
|
+
|
|
410
579
|
try {
|
|
411
|
-
// 1.
|
|
580
|
+
// 1. Middleware execution — runs for all routes handled by this function.
|
|
581
|
+
// For RSC flight requests, run middleware against the TARGET page path
|
|
582
|
+
// (from ?path= query param), not the literal /__catmint/rsc pathname.
|
|
583
|
+
var middlewareHeaders = null;
|
|
584
|
+
if (ssrEntry.executeMiddleware) {
|
|
585
|
+
try {
|
|
586
|
+
var middlewarePath = pathname;
|
|
587
|
+
if (pathname === "/__catmint/rsc") {
|
|
588
|
+
var rscTargetPath = url.searchParams.get("path");
|
|
589
|
+
if (rscTargetPath) middlewarePath = rscTargetPath;
|
|
590
|
+
}
|
|
591
|
+
var mwResult = await ssrEntry.executeMiddleware(middlewarePath, request);
|
|
592
|
+
|
|
593
|
+
if (mwResult.shortCircuit) {
|
|
594
|
+
// Middleware short-circuited — return its response directly
|
|
595
|
+
return mwResult.shortCircuit;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// Middleware passed — capture headers to merge into final response
|
|
599
|
+
if (mwResult.headers && typeof mwResult.headers.forEach === "function") {
|
|
600
|
+
middlewareHeaders = mwResult.headers;
|
|
601
|
+
}
|
|
602
|
+
} catch (err) {
|
|
603
|
+
console.error("Middleware error:", err);
|
|
604
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// Helper: create a new response with middleware headers merged in
|
|
609
|
+
function applyMiddlewareHeaders(response) {
|
|
610
|
+
if (!middlewareHeaders) return response;
|
|
611
|
+
var headers = new Headers(response.headers);
|
|
612
|
+
middlewareHeaders.forEach(function(value, key) {
|
|
613
|
+
headers.set(key, value);
|
|
614
|
+
});
|
|
615
|
+
return new Response(response.body, {
|
|
616
|
+
status: response.status,
|
|
617
|
+
headers,
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// 2. Handle server function RPC calls (/__catmint/fn/*)
|
|
412
622
|
if (pathname.startsWith("/__catmint/fn/") && ssrEntry.handleServerFn) {
|
|
623
|
+
// Enforce POST method
|
|
624
|
+
if (method !== "POST") {
|
|
625
|
+
return secureResponse(
|
|
626
|
+
JSON.stringify({ error: "Method " + method + " not allowed, expected POST" }),
|
|
627
|
+
{ status: 405, headers: { "Content-Type": "application/json" } },
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// Enforce Content-Type: application/json
|
|
632
|
+
const ct = (request.headers.get("content-type") || "").toLowerCase();
|
|
633
|
+
if (ct && !ct.startsWith("application/json")) {
|
|
634
|
+
return secureResponse(
|
|
635
|
+
JSON.stringify({ error: "Unsupported Content-Type, expected application/json" }),
|
|
636
|
+
{ status: 415, headers: { "Content-Type": "application/json" } },
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// Validate Origin header
|
|
641
|
+
const origin = request.headers.get("origin");
|
|
642
|
+
if (origin) {
|
|
643
|
+
const expectedOrigin = url.origin;
|
|
644
|
+
if (origin !== expectedOrigin) {
|
|
645
|
+
return secureResponse(
|
|
646
|
+
JSON.stringify({ error: "Origin not allowed" }),
|
|
647
|
+
{ status: 403, headers: { "Content-Type": "application/json" } },
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// Read body with size limit
|
|
653
|
+
const MAX_BODY_SIZE = ${maxBodySize};
|
|
654
|
+
const contentLength = parseInt(request.headers.get("content-length") || "0", 10);
|
|
655
|
+
if (contentLength > MAX_BODY_SIZE) {
|
|
656
|
+
return secureResponse(
|
|
657
|
+
JSON.stringify({ error: "Request body too large" }),
|
|
658
|
+
{ status: 413, headers: { "Content-Type": "application/json" } },
|
|
659
|
+
);
|
|
660
|
+
}
|
|
413
661
|
const bodyText = await request.text();
|
|
662
|
+
if (bodyText.length > MAX_BODY_SIZE) {
|
|
663
|
+
return secureResponse(
|
|
664
|
+
JSON.stringify({ error: "Request body too large" }),
|
|
665
|
+
{ status: 413, headers: { "Content-Type": "application/json" } },
|
|
666
|
+
);
|
|
667
|
+
}
|
|
414
668
|
let parsed;
|
|
415
669
|
try {
|
|
416
670
|
parsed = bodyText.length > 0 ? JSON.parse(bodyText) : undefined;
|
|
417
671
|
} catch {
|
|
418
|
-
return
|
|
672
|
+
return secureResponse(
|
|
419
673
|
JSON.stringify({ error: "Invalid JSON body" }),
|
|
420
674
|
{ status: 400, headers: { "Content-Type": "application/json" } },
|
|
421
675
|
);
|
|
422
676
|
}
|
|
423
677
|
const result = await ssrEntry.handleServerFn(pathname, parsed);
|
|
424
678
|
if (result) {
|
|
425
|
-
return
|
|
679
|
+
return applyMiddlewareHeaders(secureResponse(JSON.stringify(result.result), {
|
|
426
680
|
status: 200,
|
|
427
681
|
headers: { "Content-Type": "application/json" },
|
|
428
|
-
});
|
|
682
|
+
}));
|
|
429
683
|
}
|
|
430
|
-
return
|
|
684
|
+
return secureResponse(
|
|
431
685
|
JSON.stringify({ error: "Server function not found" }),
|
|
432
686
|
{ status: 404, headers: { "Content-Type": "application/json" } },
|
|
433
687
|
);
|
|
434
688
|
}
|
|
435
689
|
|
|
436
|
-
//
|
|
690
|
+
// 3. RSC flight stream for client-side navigation (/__catmint/rsc?path=...)
|
|
437
691
|
if (pathname === "/__catmint/rsc" && method === "GET" && rscEntry.render) {
|
|
438
692
|
const targetPath = url.searchParams.get("path");
|
|
439
693
|
if (!targetPath) {
|
|
440
|
-
return
|
|
694
|
+
return secureResponse(
|
|
441
695
|
JSON.stringify({ error: "Missing ?path= parameter" }),
|
|
442
696
|
{ status: 400, headers: { "Content-Type": "application/json" } },
|
|
443
697
|
);
|
|
@@ -445,54 +699,68 @@ export default async function handler(request) {
|
|
|
445
699
|
try {
|
|
446
700
|
const rscResult = await rscEntry.render(targetPath);
|
|
447
701
|
if (rscResult) {
|
|
448
|
-
return
|
|
702
|
+
return applyMiddlewareHeaders(secureResponse(rscResult.stream, {
|
|
449
703
|
status: 200,
|
|
450
704
|
headers: {
|
|
451
705
|
"Content-Type": "text/x-component; charset=utf-8",
|
|
452
706
|
"Cache-Control": "no-cache, no-store, must-revalidate",
|
|
453
707
|
},
|
|
454
|
-
});
|
|
708
|
+
}));
|
|
455
709
|
}
|
|
456
|
-
return
|
|
710
|
+
return secureResponse(
|
|
457
711
|
JSON.stringify({ error: "No matching route" }),
|
|
458
712
|
{ status: 404, headers: { "Content-Type": "application/json" } },
|
|
459
713
|
);
|
|
460
714
|
} catch (err) {
|
|
461
715
|
console.error("RSC navigation error:", err);
|
|
462
|
-
return
|
|
716
|
+
return secureResponse(
|
|
463
717
|
JSON.stringify({ error: "RSC navigation error" }),
|
|
464
718
|
{ status: 500, headers: { "Content-Type": "application/json" } },
|
|
465
719
|
);
|
|
466
720
|
}
|
|
467
721
|
}
|
|
468
722
|
|
|
469
|
-
//
|
|
723
|
+
// 4. API endpoint handling
|
|
470
724
|
if (ssrEntry.hasEndpoint && ssrEntry.hasEndpoint(pathname)) {
|
|
471
725
|
const result = await ssrEntry.handleEndpoint(pathname, method, request);
|
|
472
726
|
|
|
473
727
|
if (result) {
|
|
474
|
-
return result.response;
|
|
728
|
+
return applyMiddlewareHeaders(result.response);
|
|
475
729
|
}
|
|
476
730
|
|
|
477
|
-
return
|
|
731
|
+
return secureResponse(\`Method \${method} not allowed\`, {
|
|
478
732
|
status: 405,
|
|
479
733
|
headers: { "Content-Type": "text/plain" },
|
|
480
734
|
});
|
|
481
735
|
}
|
|
482
736
|
|
|
483
|
-
//
|
|
737
|
+
// 5. Pre-rendered pages WITH middleware: serve from inlined prerendered map.
|
|
738
|
+
if (method === "GET" && typeof prerenderedPages !== "undefined") {
|
|
739
|
+
const prHtml = prerenderedPages[pathname];
|
|
740
|
+
if (prHtml) {
|
|
741
|
+
return applyMiddlewareHeaders(secureResponse(prHtml, {
|
|
742
|
+
status: 200,
|
|
743
|
+
headers: {
|
|
744
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
745
|
+
"Cache-Control": "public, max-age=0, must-revalidate",
|
|
746
|
+
},
|
|
747
|
+
}));
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// 6. RSC → SSR page rendering pipeline
|
|
484
752
|
if (method === "GET" && rscEntry.render) {
|
|
485
753
|
const rscResult = await rscEntry.render(pathname);
|
|
486
754
|
if (rscResult) {
|
|
487
755
|
const htmlStream = await ssrEntry.renderToHtml(rscResult.stream, rscResult.headConfig);
|
|
488
|
-
return
|
|
756
|
+
return applyMiddlewareHeaders(secureResponse(htmlStream, {
|
|
489
757
|
status: 200,
|
|
490
758
|
headers: { "Content-Type": "text/html; charset=utf-8" },
|
|
491
|
-
});
|
|
759
|
+
}));
|
|
492
760
|
}
|
|
493
761
|
}
|
|
494
762
|
|
|
495
|
-
//
|
|
763
|
+
// 7. Fallback 404
|
|
496
764
|
return await statusPageResponse(404, pathname);
|
|
497
765
|
} catch (err) {
|
|
498
766
|
console.error("Edge function error:", err);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AAsB,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CACjD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,UAAU,KAAK,QAAQ,CACpD,CAAC;IAEF,OAAO;;;EAGP,sBAAsB,CAAC,CAAC,CAAC,sDAAsD,CAAC,CAAC,CAAC,EAAE;EACpF,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAkEc,YAAY,KAAK,UAAU,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,EAAE;;;EAInG,YAAY,KAAK,UAAU;QACzB,CAAC,CAAC;;;CAGL;QACG,CAAC,CAAC,EACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BA6E8B,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqHxC,CAAC;AACF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,13 @@ export interface VercelAdapterOptions {
|
|
|
7
7
|
runtime?: "nodejs" | "edge";
|
|
8
8
|
/** Vercel regions to deploy to */
|
|
9
9
|
regions?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Maximum allowed request body size in bytes.
|
|
12
|
+
* Applies to server function RPC calls and API endpoints.
|
|
13
|
+
*
|
|
14
|
+
* @default 1_048_576 (1 MB)
|
|
15
|
+
*/
|
|
16
|
+
maxBodySize?: number;
|
|
10
17
|
}
|
|
11
18
|
/**
|
|
12
19
|
* Create a Vercel adapter for Catmint.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,gBAAgB,CAAC;AAmExB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC5B,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,cAAc,CA6MhB"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,52 @@
|
|
|
1
1
|
// @catmint/adapter-vercel — Vercel deployment adapter
|
|
2
|
-
import { join } from "node:path";
|
|
2
|
+
import { join, relative } from "node:path";
|
|
3
|
+
import { readFileSync, readdirSync, statSync, existsSync } from "node:fs";
|
|
3
4
|
import { generateVercelConfig } from "./config-gen.js";
|
|
4
5
|
import { generateServerlessFunction, generateVcConfig, } from "./function-gen.js";
|
|
6
|
+
/**
|
|
7
|
+
* Generate a JS module that exports a map of pathname → HTML string
|
|
8
|
+
* for prerendered pages. Used by edge runtimes that cannot read from
|
|
9
|
+
* the filesystem at runtime.
|
|
10
|
+
*/
|
|
11
|
+
function generatePrerenderedModule(prerenderedDir) {
|
|
12
|
+
const entries = [];
|
|
13
|
+
function walk(dir) {
|
|
14
|
+
if (!existsSync(dir))
|
|
15
|
+
return;
|
|
16
|
+
for (const entry of readdirSync(dir)) {
|
|
17
|
+
const fullPath = join(dir, entry);
|
|
18
|
+
const stat = statSync(fullPath);
|
|
19
|
+
if (stat.isDirectory()) {
|
|
20
|
+
walk(fullPath);
|
|
21
|
+
}
|
|
22
|
+
else if (entry.endsWith(".html")) {
|
|
23
|
+
const relPath = relative(prerenderedDir, fullPath);
|
|
24
|
+
let pathname = "/" + relPath.replace(/\\/g, "/");
|
|
25
|
+
if (pathname.endsWith("/index.html")) {
|
|
26
|
+
pathname = pathname.slice(0, -"/index.html".length) || "/";
|
|
27
|
+
}
|
|
28
|
+
else if (pathname.endsWith(".html")) {
|
|
29
|
+
pathname = pathname.slice(0, -".html".length);
|
|
30
|
+
}
|
|
31
|
+
const html = readFileSync(fullPath, "utf-8");
|
|
32
|
+
entries.push({ pathname, html });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
walk(prerenderedDir);
|
|
37
|
+
if (entries.length === 0) {
|
|
38
|
+
return `// No prerendered pages\nexport const prerenderedPages = {};\n`;
|
|
39
|
+
}
|
|
40
|
+
const lines = [
|
|
41
|
+
"// Auto-generated prerendered page map — do not edit",
|
|
42
|
+
"export const prerenderedPages = {",
|
|
43
|
+
];
|
|
44
|
+
for (const { pathname, html } of entries) {
|
|
45
|
+
lines.push(` ${JSON.stringify(pathname)}: ${JSON.stringify(html)},`);
|
|
46
|
+
}
|
|
47
|
+
lines.push("};");
|
|
48
|
+
return lines.join("\n") + "\n";
|
|
49
|
+
}
|
|
5
50
|
/**
|
|
6
51
|
* Create a Vercel adapter for Catmint.
|
|
7
52
|
*
|
|
@@ -20,6 +65,7 @@ import { generateServerlessFunction, generateVcConfig, } from "./function-gen.js
|
|
|
20
65
|
export default function vercelAdapter(options) {
|
|
21
66
|
const runtime = options?.runtime ?? "nodejs";
|
|
22
67
|
const regions = options?.regions;
|
|
68
|
+
const maxBodySize = options?.maxBodySize ?? 1_048_576;
|
|
23
69
|
return {
|
|
24
70
|
name: "@catmint/adapter-vercel",
|
|
25
71
|
async adapt(context) {
|
|
@@ -39,6 +85,8 @@ export default function vercelAdapter(options) {
|
|
|
39
85
|
await context.copyDir(context.clientDir, staticOutputDir);
|
|
40
86
|
context.log("@catmint/adapter-vercel: Copied client assets to static/");
|
|
41
87
|
// 3. Copy pre-rendered static pages to static/
|
|
88
|
+
// NOTE: Middleware-protected static pages are NOT copied here — they
|
|
89
|
+
// are served through the serverless function after middleware runs.
|
|
42
90
|
await context.copyDir(context.staticDir, staticOutputDir);
|
|
43
91
|
context.log("@catmint/adapter-vercel: Copied pre-rendered pages to static/");
|
|
44
92
|
// 4. Generate serverless function (only if not frontend-only mode)
|
|
@@ -52,10 +100,25 @@ export default function vercelAdapter(options) {
|
|
|
52
100
|
// import both without filename conflicts.
|
|
53
101
|
await context.copyDir(context.serverDir, join(funcDir, "ssr"));
|
|
54
102
|
await context.copyDir(rscDir, join(funcDir, "rsc"));
|
|
103
|
+
// If there are prerendered pages with middleware, handle them based
|
|
104
|
+
// on the runtime:
|
|
105
|
+
// - Node.js: copy files to function dir (served via filesystem reads)
|
|
106
|
+
// - Edge: generate a JS module with inlined HTML (no fs access at runtime)
|
|
107
|
+
if (context.prerenderedDir && existsSync(context.prerenderedDir)) {
|
|
108
|
+
if (runtime === "edge") {
|
|
109
|
+
const prerenderedModule = generatePrerenderedModule(context.prerenderedDir);
|
|
110
|
+
await context.writeFile(join(funcDir, "prerendered.js"), prerenderedModule);
|
|
111
|
+
context.log("@catmint/adapter-vercel: Generated prerendered.js module (middleware-protected, edge)");
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
await context.copyDir(context.prerenderedDir, join(funcDir, "prerendered"));
|
|
115
|
+
context.log("@catmint/adapter-vercel: Copied prerendered HTML to function (middleware-protected)");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
55
118
|
// Generate the serverless function entry as handler.js.
|
|
56
119
|
// This imports from ./ssr/index.js and ./rsc/index.js and wraps
|
|
57
120
|
// them with the Vercel serverless function handler signature.
|
|
58
|
-
const functionEntry = generateServerlessFunction(manifest, runtime);
|
|
121
|
+
const functionEntry = generateServerlessFunction(manifest, runtime, maxBodySize, manifest.config.security.headerPreset);
|
|
59
122
|
await context.writeFile(join(funcDir, "handler.js"), functionEntry);
|
|
60
123
|
// Add package.json with "type": "module" so Node.js treats .js as ESM.
|
|
61
124
|
// The function directory is isolated from the project root, so without
|
|
@@ -81,6 +144,15 @@ export default function vercelAdapter(options) {
|
|
|
81
144
|
// The route function re-uses the same serverless entry and server bundle
|
|
82
145
|
await context.copyDir(context.serverDir, join(routeFuncDir, "ssr"));
|
|
83
146
|
await context.copyDir(rscDir, join(routeFuncDir, "rsc"));
|
|
147
|
+
if (context.prerenderedDir && existsSync(context.prerenderedDir)) {
|
|
148
|
+
if (runtime === "edge") {
|
|
149
|
+
const prerenderedModule = generatePrerenderedModule(context.prerenderedDir);
|
|
150
|
+
await context.writeFile(join(routeFuncDir, "prerendered.js"), prerenderedModule);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
await context.copyDir(context.prerenderedDir, join(routeFuncDir, "prerendered"));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
84
156
|
await context.writeFile(join(routeFuncDir, "handler.js"), functionEntry);
|
|
85
157
|
await context.writeFile(join(routeFuncDir, "package.json"), JSON.stringify({ type: "module" }, null, 2));
|
|
86
158
|
await context.writeFile(join(routeFuncDir, ".vc-config.json"), JSON.stringify(vcConfig, null, 2));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAOtD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;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EAAgE,CACjE,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,yBAAyB,CAChC,QAAqB,EACrB,OAAuB;IAEvB,gDAAgD;IAChD,IAAI,QAAQ,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxC,OAAO,CAAC,GAAG,CACT,kFAAkF;YAChF,qFAAqF,CACxF,CAAC;IACJ,CAAC;IAED,MAAM,kBAAkB,GAAG;QACzB,OAAO;QACP,IAAI;QACJ,eAAe;QACf,SAAS;QACT,OAAO;QACP,KAAK;QACL,KAAK;QACL,KAAK;KACN,CAAC;IACF,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,eAAe,EAAE,CAAC;QAC1C,KAAK,MAAM,SAAS,IAAI,kBAAkB,EAAE,CAAC;YAC3C,IAAI,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAClC,OAAO,CAAC,GAAG,CACT,uDAAuD,EAAE,CAAC,IAAI,gBAAgB;oBAC5E,aAAa,SAAS,kDAAkD,CAC3E,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@catmint/adapter-vercel",
|
|
3
|
-
"version": "0.0.0-prealpha.
|
|
3
|
+
"version": "0.0.0-prealpha.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"catmint": "0.0.0-prealpha.
|
|
17
|
+
"catmint": "0.0.0-prealpha.10"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"typescript": "^5.7.0"
|