@analogjs/vite-plugin-nitro 2.4.0-beta.6 → 3.0.0-alpha.1
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 +2 -2
- package/package.json +4 -2
- package/src/index.d.ts +1 -1
- package/src/lib/build-server.d.ts +1 -1
- package/src/lib/build-server.js +30 -3
- package/src/lib/build-server.js.map +1 -1
- package/src/lib/hooks/post-rendering-hook.d.ts +1 -1
- package/src/lib/options.d.ts +1 -1
- package/src/lib/plugins/dev-server-plugin.js +4 -2
- package/src/lib/plugins/dev-server-plugin.js.map +1 -1
- package/src/lib/plugins/page-endpoints.js +33 -10
- package/src/lib/plugins/page-endpoints.js.map +1 -1
- package/src/lib/utils/get-content-files.js +1 -4
- package/src/lib/utils/get-content-files.js.map +1 -1
- package/src/lib/utils/get-page-handlers.d.ts +1 -1
- package/src/lib/utils/get-page-handlers.js +5 -3
- package/src/lib/utils/get-page-handlers.js.map +1 -1
- package/src/lib/utils/node-web-bridge.d.ts +3 -0
- package/src/lib/utils/node-web-bridge.js +50 -0
- package/src/lib/utils/node-web-bridge.js.map +1 -0
- package/src/lib/utils/register-dev-middleware.d.ts +4 -32
- package/src/lib/utils/register-dev-middleware.js +22 -43
- package/src/lib/utils/register-dev-middleware.js.map +1 -1
- package/src/lib/utils/renderers.d.ts +42 -3
- package/src/lib/utils/renderers.js +98 -26
- package/src/lib/utils/renderers.js.map +1 -1
- package/src/lib/vite-plugin-nitro.d.ts +1 -1
- package/src/lib/vite-plugin-nitro.js +207 -68
- package/src/lib/vite-plugin-nitro.js.map +1 -1
package/README.md
CHANGED
|
@@ -81,9 +81,9 @@ and are exposed under the default `/api` prefix.
|
|
|
81
81
|
|
|
82
82
|
```ts
|
|
83
83
|
// src/server/routes/api/v1/hello
|
|
84
|
-
import {
|
|
84
|
+
import { defineHandler } from 'h3';
|
|
85
85
|
|
|
86
|
-
export default
|
|
86
|
+
export default defineHandler(() => ({ message: 'Hello World' }));
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
The API route can be accessed as `/api/v1/hello`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@analogjs/vite-plugin-nitro",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.1",
|
|
4
4
|
"description": "A Vite plugin for adding a nitro API server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Brandon Roberts <robertsbt@gmail.com>",
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
"url": "https://github.com/sponsors/brandonroberts"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"
|
|
33
|
+
"nitro": "3.0.1-alpha.2",
|
|
34
|
+
"h3": "2.0.1-rc.16",
|
|
35
|
+
"ofetch": "2.0.0-alpha.3",
|
|
34
36
|
"xmlbuilder2": "^4.0.3",
|
|
35
37
|
"esbuild": "^0.27.3",
|
|
36
38
|
"radix3": "^1.1.2",
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nitro } from './lib/vite-plugin-nitro.js';
|
|
2
2
|
export { Options, SitemapConfig, PrerenderRouteConfig, PrerenderContentDir, PrerenderContentFile, } from './lib/options.js';
|
|
3
|
-
declare module '
|
|
3
|
+
declare module 'nitro/types' {
|
|
4
4
|
interface NitroRouteConfig {
|
|
5
5
|
ssr?: boolean;
|
|
6
6
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NitroConfig } from '
|
|
1
|
+
import type { NitroConfig } from 'nitro/types';
|
|
2
2
|
import { Options } from './options.js';
|
|
3
3
|
export declare function buildServer(options?: Options, nitroConfig?: NitroConfig, routeSourceFiles?: Record<string, string>): Promise<void>;
|
package/src/lib/build-server.js
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
|
-
import { copyPublicAssets, prerender } from '
|
|
2
|
-
import { createNitro, build, prepare } from 'nitropack';
|
|
1
|
+
import { build, copyPublicAssets, createNitro, prepare, prerender, } from 'nitro/builder';
|
|
3
2
|
import { existsSync, mkdirSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
4
3
|
import { dirname, join } from 'node:path';
|
|
5
4
|
import { addPostRenderingHooks } from './hooks/post-rendering-hook.js';
|
|
5
|
+
function isVercelPreset(preset) {
|
|
6
|
+
return !!preset?.toLowerCase().includes('vercel');
|
|
7
|
+
}
|
|
8
|
+
function ensureVercelFunctionConfig(nitro) {
|
|
9
|
+
if (!isVercelPreset(nitro.options.preset)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const serverDir = nitro.options.output.serverDir;
|
|
13
|
+
const functionConfigPath = join(serverDir, '.vc-config.json');
|
|
14
|
+
if (existsSync(functionConfigPath)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
mkdirSync(serverDir, { recursive: true });
|
|
18
|
+
writeFileSync(functionConfigPath, JSON.stringify({
|
|
19
|
+
handler: 'index.mjs',
|
|
20
|
+
launcherType: 'Nodejs',
|
|
21
|
+
shouldAddHelpers: false,
|
|
22
|
+
supportsResponseStreaming: true,
|
|
23
|
+
...nitro.options.vercel?.functions,
|
|
24
|
+
}, null, 2), 'utf8');
|
|
25
|
+
}
|
|
6
26
|
export async function buildServer(options, nitroConfig, routeSourceFiles) {
|
|
7
27
|
const nitro = await createNitro({
|
|
8
28
|
dev: false,
|
|
9
29
|
preset: process.env['BUILD_PRESET'],
|
|
10
30
|
...nitroConfig,
|
|
31
|
+
// Nitro v3 alpha prefers `rolldown` when available, but its resolver can
|
|
32
|
+
// fail rebundling the generated SSR entry under `dist/.../main.server.js`
|
|
33
|
+
// with Vite 8 / Rolldown-specific "Tsconfig not found" resolve errors.
|
|
34
|
+
// Default production server builds back to Nitro's Rollup builder unless
|
|
35
|
+
// the caller explicitly opts into a different builder.
|
|
36
|
+
builder: nitroConfig?.builder ?? 'rollup',
|
|
11
37
|
});
|
|
12
38
|
if (options?.prerender?.postRenderingHooks) {
|
|
13
39
|
addPostRenderingHooks(nitro, options.prerender.postRenderingHooks);
|
|
@@ -21,7 +47,7 @@ export async function buildServer(options, nitroConfig, routeSourceFiles) {
|
|
|
21
47
|
const indexFileExts = ['', '.br', '.gz'];
|
|
22
48
|
indexFileExts.forEach((fileExt) => {
|
|
23
49
|
// Remove the root index.html(.br|.gz) files
|
|
24
|
-
const indexFilePath =
|
|
50
|
+
const indexFilePath = join(nitroConfig?.output?.publicDir ?? '', `index.html${fileExt}`);
|
|
25
51
|
if (existsSync(indexFilePath)) {
|
|
26
52
|
unlinkSync(indexFilePath);
|
|
27
53
|
}
|
|
@@ -49,6 +75,7 @@ export async function buildServer(options, nitroConfig, routeSourceFiles) {
|
|
|
49
75
|
if (!options?.static) {
|
|
50
76
|
console.log('Building Server...');
|
|
51
77
|
await build(nitro);
|
|
78
|
+
ensureVercelFunctionConfig(nitro);
|
|
52
79
|
}
|
|
53
80
|
await nitro.close();
|
|
54
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-server.js","sourceRoot":"","sources":["../../../../../packages/vite-plugin-nitro/src/lib/build-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-server.js","sourceRoot":"","sources":["../../../../../packages/vite-plugin-nitro/src/lib/build-server.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,SAAS,cAAc,CAAC,MAA0B;IAChD,OAAO,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,C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C,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAChE,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,GAAG,KAAK,KAAK,CAAC,CAAC;YAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;YAEtC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC3B,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC5C,CAAC;YAED,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAClC,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC;QACnB,0BAA0B,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Nitro, PrerenderRoute } from '
|
|
1
|
+
import type { Nitro, PrerenderRoute } from 'nitro/types';
|
|
2
2
|
export declare function addPostRenderingHooks(nitro: Nitro, hooks: ((pr: PrerenderRoute) => Promise<void>)[]): void;
|
package/src/lib/options.d.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { normalizePath, } from 'vite';
|
|
4
4
|
import { resolve } from 'node:path';
|
|
5
5
|
import { readFileSync } from 'node:fs';
|
|
6
|
-
import { createEvent, sendWebResponse } from 'h3';
|
|
7
6
|
import { createRouter as createRadixRouter, toRouteMatcher } from 'radix3';
|
|
8
7
|
import { defu } from 'defu';
|
|
9
8
|
import { registerDevServerMiddleware } from '../utils/register-dev-middleware.js';
|
|
9
|
+
import { writeWebResponseToNode } from '../utils/node-web-bridge.js';
|
|
10
10
|
export function devServerPlugin(options) {
|
|
11
11
|
const workspaceRoot = options?.workspaceRoot || process.cwd();
|
|
12
12
|
const sourceRoot = options?.sourceRoot ?? 'src';
|
|
@@ -21,6 +21,7 @@ export function devServerPlugin(options) {
|
|
|
21
21
|
root = normalizePath(resolve(workspaceRoot, config.root || '.') || '.');
|
|
22
22
|
isTest = isTest ? isTest : mode === 'test';
|
|
23
23
|
return {
|
|
24
|
+
appType: 'custom',
|
|
24
25
|
resolve: {
|
|
25
26
|
alias: {
|
|
26
27
|
'~analog/entry-server': options.entryServer || `${root}/${sourceRoot}/main.server.ts`,
|
|
@@ -54,7 +55,7 @@ export function devServerPlugin(options) {
|
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
if (result instanceof Response) {
|
|
57
|
-
|
|
58
|
+
await writeWebResponseToNode(res, result);
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
61
|
res.setHeader('Content-Type', 'text/html');
|
|
@@ -94,6 +95,7 @@ function remove_html_middlewares(server) {
|
|
|
94
95
|
'viteIndexHtmlMiddleware',
|
|
95
96
|
'vite404Middleware',
|
|
96
97
|
'viteSpaFallbackMiddleware',
|
|
98
|
+
'viteHtmlFallbackMiddleware',
|
|
97
99
|
];
|
|
98
100
|
for (let i = server.stack.length - 1; i > 0; i--) {
|
|
99
101
|
const handler = server.stack[i]?.handle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server-plugin.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-nitro/src/lib/plugins/dev-server-plugin.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,gFAAgF;AAEhF,OAAO,EAKL,aAAa,GACd,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"dev-server-plugin.js","sourceRoot":"","sources":["../../../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CAAC,WAAW,CAAC,EAAE,CAAC;YAC1D,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,GAA4B,EAAE,KAAc;IAChE,MAAM,CAAC,GAAG,KAAc,CAAC;IACzB,OAAO;QACL,OAAO,EAAE,2CAA2C,GAAG,CAAC,GAAG,UACzD,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAChC,GAAG;QACH,KAAK,EAAE,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK;KAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -23,8 +23,24 @@ export function pageEndpointsPlugin() {
|
|
|
23
23
|
fileExports = compiled.metafile?.outputs[key].exports;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
// In h3 v2 / Nitro v3, event.node is undefined during prerendering
|
|
27
|
+
// (which uses the fetch-based pipeline, not Node.js http). We use
|
|
28
|
+
// optional chaining so that page endpoints work in both Node.js
|
|
29
|
+
// server and fetch-based prerender contexts.
|
|
30
|
+
// Nitro v3 no longer guarantees the private `nitro/deps/ofetch`
|
|
31
|
+
// subpath that older codegen relied on.
|
|
32
|
+
//
|
|
33
|
+
// Page loaders expect Nitro-style `$fetch` semantics (parsed data plus
|
|
34
|
+
// internal relative-route support), so construct a request-local fetch
|
|
35
|
+
// using public APIs:
|
|
36
|
+
// - `createFetch` from `ofetch` for `$fetch` behavior
|
|
37
|
+
// - `fetchWithEvent` from `h3` for internal Nitro request routing
|
|
38
|
+
//
|
|
39
|
+
// This avoids both unstable private Nitro imports and assumptions about
|
|
40
|
+
// a global runtime `$fetch` being available during prerender.
|
|
26
41
|
const code = `
|
|
27
|
-
import {
|
|
42
|
+
import { defineHandler, fetchWithEvent } from 'h3';
|
|
43
|
+
import { createFetch } from 'ofetch';
|
|
28
44
|
|
|
29
45
|
${fileExports.includes('load')
|
|
30
46
|
? _code
|
|
@@ -39,17 +55,24 @@ export function pageEndpointsPlugin() {
|
|
|
39
55
|
: `
|
|
40
56
|
export const action = () => {
|
|
41
57
|
return {};
|
|
42
|
-
}
|
|
58
|
+
}
|
|
43
59
|
`}
|
|
44
60
|
|
|
45
|
-
export default
|
|
61
|
+
export default defineHandler(async(event) => {
|
|
62
|
+
const serverFetch = createFetch({
|
|
63
|
+
fetch: (resource, init) => {
|
|
64
|
+
const url = resource instanceof Request ? resource.url : resource.toString();
|
|
65
|
+
return fetchWithEvent(event, url, init);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
46
69
|
if (event.method === 'GET') {
|
|
47
70
|
try {
|
|
48
71
|
return await load({
|
|
49
72
|
params: event.context.params,
|
|
50
|
-
req: event.node
|
|
51
|
-
res: event.node
|
|
52
|
-
fetch:
|
|
73
|
+
req: event.node?.req,
|
|
74
|
+
res: event.node?.res,
|
|
75
|
+
fetch: serverFetch,
|
|
53
76
|
event
|
|
54
77
|
});
|
|
55
78
|
} catch(e) {
|
|
@@ -60,15 +83,15 @@ export function pageEndpointsPlugin() {
|
|
|
60
83
|
try {
|
|
61
84
|
return await action({
|
|
62
85
|
params: event.context.params,
|
|
63
|
-
req: event.node
|
|
64
|
-
res: event.node
|
|
65
|
-
fetch:
|
|
86
|
+
req: event.node?.req,
|
|
87
|
+
res: event.node?.res,
|
|
88
|
+
fetch: serverFetch,
|
|
66
89
|
event
|
|
67
90
|
});
|
|
68
91
|
} catch(e) {
|
|
69
92
|
console.error(\` An error occurred: \${e}\`)
|
|
70
93
|
throw e;
|
|
71
|
-
}
|
|
94
|
+
}
|
|
72
95
|
}
|
|
73
96
|
});
|
|
74
97
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-endpoints.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-nitro/src/lib/plugins/page-endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAErC,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,IAAI,EAAE,iDAAiD;QACvD,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,EAAU;YACvC,IAAI,aAAa,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBACvE,MAAM,QAAQ,GAAG,SAAS,CAAC;oBACzB,KAAK,EAAE;wBACL,QAAQ,EAAE,KAAK;wBACf,UAAU,EAAE,EAAE;wBACd,MAAM,EAAE,IAAI;qBACb;oBACD,KAAK,EAAE,KAAK;oBACZ,QAAQ,EAAE,IAAI;oBACd,QAAQ,EAAE,SAAS;oBACnB,MAAM,EAAE,KAAK;oBACb,QAAQ,EAAE,QAAQ;iBACnB,CAAC,CAAC;gBAEH,IAAI,WAAW,GAAa,EAAE,CAAC;gBAE/B,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;oBAC7C,IAAI,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;wBAC/C,WAAW,GAAG,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;oBACxD,CAAC;gBACH,CAAC;gBAED,MAAM,IAAI,GAAG
|
|
1
|
+
{"version":3,"file":"page-endpoints.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-nitro/src/lib/plugins/page-endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAErC,MAAM,UAAU,mB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C5B,CAAC,CAAC,EAAE;oBACJ,CAAC,CAAC;;;;eAKN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAsCD,CAAC;gBAEJ,OAAO;oBACL,IAAI;oBACJ,GAAG,EAAE,IAAI;iBACV,CAAC;YACJ,CAAC;YAED,OAAO;QACT,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -78,10 +78,7 @@ export function getMatchingContentFilesWithFrontMatter(workspaceRoot, rootDir, g
|
|
|
78
78
|
const fileContents = readFileSync(f, 'utf8');
|
|
79
79
|
// Parse front matter from the file content
|
|
80
80
|
const raw = fm(fileContents);
|
|
81
|
-
|
|
82
|
-
const filepath = f.replace(root, '');
|
|
83
|
-
// Extract file name and extension using regex
|
|
84
|
-
// Matches: /filename.ext or /filename (with optional extension)
|
|
81
|
+
const filepath = normalizePath(f).replace(root, '');
|
|
85
82
|
const match = filepath.match(/\/([^/.]+)(\.([^/.]+))?$/);
|
|
86
83
|
let name = '';
|
|
87
84
|
let extension = '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-content-files.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-nitro/src/lib/utils/get-content-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,UAAU,sCAAsC,CACpD,aAAqB,EACrB,OAAe,EACf,IAAY;IAEZ,2CAA2C;IAC3C,8DAA8D;IAC9D,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAEnC,+DAA+D;IAC/D,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAE5D,kEAAkE;IAClE,MAAM,WAAW,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAEpE,wDAAwD;IACxD,yDAAyD;IACzD,MAAM,YAAY,GAAa,QAAQ,CAAC,CAAC,GAAG,IAAI,IAAI,WAAW,IAAI,CAAC,EAAE;QACpE,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IAEH,4EAA4E;IAC5E,MAAM,iBAAiB,GAA2B,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACvE,uCAAuC;QACvC,MAAM,YAAY,GAAG,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QAE7C,2CAA2C;QAC3C,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC;QAE7B,
|
|
1
|
+
{"version":3,"file":"get-content-files.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-nitro/src/lib/utils/get-content-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C;;;;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,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,iDAAiD;QAC/E,CAAC;QAED,uDAAuD;QACvD,OAAO;YACL,IAAI;YACJ,SAAS;YACT,IAAI,EAAE,WAAW;YACjB,UAAU,EAAE,GAAG,CAAC,UAAiD;YACjE,OAAO,EAAE,YAAY;SACtB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
|
|
@@ -64,9 +64,11 @@ export function getPageHandlers({ workspaceRoot, sourceRoot, rootDir, additional
|
|
|
64
64
|
], { dot: true, absolute: true });
|
|
65
65
|
// Transform each discovered file into a Nitro event handler
|
|
66
66
|
const handlers = endpointFiles.map((endpointFile) => {
|
|
67
|
-
//
|
|
68
|
-
const
|
|
69
|
-
|
|
67
|
+
// Normalize the endpoint file path for consistent path handling
|
|
68
|
+
const normalized = normalizePath(endpointFile);
|
|
69
|
+
// Transform the normalized path into a route pattern
|
|
70
|
+
const route = normalized
|
|
71
|
+
.replace(/^(.*?)\/pages/, '/pages')
|
|
70
72
|
.replace(/\.server\.ts$/, '') // Remove .server.ts extension
|
|
71
73
|
.replace(/\[\.{3}(.+)\]/g, '**:$1') // Convert [...param] to **:param (catch-all routes)
|
|
72
74
|
.replace(/\[\.{3}(\w+)\]/g, '**:$1') // Alternative catch-all pattern
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-page-handlers.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-nitro/src/lib/utils/get-page-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAUrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,aAAa,EACb,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,SAAS,GACO;IAChB,+DAA+D;IAC/D,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAE5D,4FAA4F;IAC5F,iGAAiG;IACjG,MAAM,aAAa,GAAa,QAAQ,CACtC;QACE,GAAG,IAAI,IAAI,UAAU,2BAA2B;QAChD,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC,GAAG,CAChC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,aAAa,GAAG,GAAG,iBAAiB,CACjD;KACF,EACD,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAC9B,CAAC;IAEF,4DAA4D;IAC5D,MAAM,QAAQ,GAAwB,aAAa,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE;QACvE,
|
|
1
|
+
{"version":3,"file":"get-page-handlers.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-nitro/src/lib/utils/get-page-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAUrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,aAAa,EACb,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,SAAS,GACO;IAChB,+DAA+D;IAC/D,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAE5D,4FAA4F;IAC5F,iGAAiG;IACjG,MAAM,aAAa,GAAa,QAAQ,CACtC;QACE,GAAG,IAAI,IAAI,UAAU,2BAA2B;QAChD,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC,GAAG,CAChC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,aAAa,GAAG,GAAG,iBAAiB,CACjD;KACF,EACD,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAC9B,CAAC;IAEF,4DAA4D;IAC5D,MAAM,QAAQ,GAAwB,aAAa,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE;QACvE,gEAAgE;QAChE,MAAM,UAAU,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;QAC/C,qDAAqD;QACrD,MAAM,KAAK,GAAG,UAAU;aACrB,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC;aAClC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,8BAA8B;aAC3D,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,oDAAoD;aACvF,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,gCAAgC;aACpE,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,4CAA4C;aAC7E,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,6CAA6C;aAC1E,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,kCAAkC;QAE1D,8EAA8E;QAC9E,OAAO;YACL,OAAO,EAAE,YAAY;YACrB,KAAK,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,KAAK,EAAE;YACnD,IAAI,EAAE,IAAI;SACX,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { pipeline } from 'node:stream/promises';
|
|
3
|
+
function toWebHeaders(headers) {
|
|
4
|
+
return Object.entries(headers).reduce((acc, [key, value]) => {
|
|
5
|
+
if (value) {
|
|
6
|
+
acc.set(key, Array.isArray(value) ? value.join(', ') : value);
|
|
7
|
+
}
|
|
8
|
+
return acc;
|
|
9
|
+
}, new Headers());
|
|
10
|
+
}
|
|
11
|
+
export function toWebRequest(req) {
|
|
12
|
+
const protocol = 'http';
|
|
13
|
+
const host = req.headers.host || 'localhost';
|
|
14
|
+
const url = new URL(req.url || '/', `${protocol}://${host}`);
|
|
15
|
+
const body = req.method && !['GET', 'HEAD'].includes(req.method)
|
|
16
|
+
? Readable.toWeb(req)
|
|
17
|
+
: undefined;
|
|
18
|
+
return new Request(url, {
|
|
19
|
+
method: req.method,
|
|
20
|
+
headers: toWebHeaders(req.headers),
|
|
21
|
+
body,
|
|
22
|
+
// @ts-expect-error duplex is required for streaming request bodies in Node.js
|
|
23
|
+
duplex: body ? 'half' : undefined,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export async function writeWebResponseToNode(res, response) {
|
|
27
|
+
res.statusCode = response.status;
|
|
28
|
+
res.statusMessage = response.statusText;
|
|
29
|
+
const setCookies = 'getSetCookie' in response.headers &&
|
|
30
|
+
typeof response.headers.getSetCookie === 'function'
|
|
31
|
+
? response.headers.getSetCookie()
|
|
32
|
+
: [];
|
|
33
|
+
if (setCookies.length > 0) {
|
|
34
|
+
res.setHeader('set-cookie', setCookies);
|
|
35
|
+
}
|
|
36
|
+
response.headers.forEach((value, key) => {
|
|
37
|
+
if (key !== 'set-cookie') {
|
|
38
|
+
res.setHeader(key, value);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (!response.body) {
|
|
42
|
+
res.end();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
// The Web ReadableStream and Node.js stream/web ReadableStream types
|
|
46
|
+
// are structurally identical at runtime but TypeScript treats them as
|
|
47
|
+
// distinct nominal types. The double-cast bridges this gap safely.
|
|
48
|
+
await pipeline(Readable.fromWeb(response.body), res);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=node-web-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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discovering and loading middleware files.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* 4. Handles middleware execution flow and error handling
|
|
5
|
+
* Each discovered h3 middleware module is loaded through Vite's SSR loader,
|
|
6
|
+
* wrapped in a temporary H3 app, then bridged back into Vite's Connect stack.
|
|
7
|
+
* If the middleware does not write a response, control falls through to the
|
|
8
|
+
* next Vite middleware.
|
|
10
9
|
*
|
|
11
10
|
* @param root The project root directory path
|
|
12
11
|
* @param sourceRoot The source directory path (e.g., 'src')
|
|
13
12
|
* @param viteServer The Vite development server instance
|
|
14
|
-
*
|
|
15
|
-
* Example usage:
|
|
16
|
-
* await registerDevServerMiddleware('/workspace/my-app', 'src', viteServer);
|
|
17
|
-
*
|
|
18
|
-
* Sample middleware file paths that would be discovered:
|
|
19
|
-
* - /workspace/my-app/src/server/middleware/auth.ts
|
|
20
|
-
* - /workspace/my-app/src/server/middleware/cors.ts
|
|
21
|
-
* - /workspace/my-app/src/server/middleware/logging.ts
|
|
22
|
-
* - /workspace/my-app/src/server/middleware/validation.ts
|
|
23
|
-
*
|
|
24
|
-
* tinyglobby vs fast-glob comparison:
|
|
25
|
-
* - Both support the same glob patterns for file discovery
|
|
26
|
-
* - Both are efficient for finding middleware files
|
|
27
|
-
* - tinyglobby is now used instead of fast-glob
|
|
28
|
-
* - tinyglobby provides similar functionality with smaller bundle size
|
|
29
|
-
* - tinyglobby's globSync returns absolute paths when absolute: true is set
|
|
30
|
-
*
|
|
31
|
-
* globSync options explained:
|
|
32
|
-
* - dot: true - Includes files/directories that start with a dot (e.g., .env.middleware)
|
|
33
|
-
* - absolute: true - Returns absolute file paths instead of relative paths
|
|
34
|
-
*
|
|
35
|
-
* Middleware execution flow:
|
|
36
|
-
* 1. Request comes to Vite dev server
|
|
37
|
-
* 2. Each registered middleware is executed in order
|
|
38
|
-
* 3. If middleware returns a result, request processing stops
|
|
39
|
-
* 4. If middleware returns no result, next middleware is called
|
|
40
|
-
* 5. If no middleware handles the request, it continues to normal Vite processing
|
|
41
13
|
*/
|
|
42
14
|
export declare function registerDevServerMiddleware(root: string, sourceRoot: string, viteServer: ViteDevServer): Promise<void>;
|
|
@@ -1,67 +1,46 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H3 } from 'h3';
|
|
2
2
|
import { globSync } from 'tinyglobby';
|
|
3
|
+
import { toWebRequest, writeWebResponseToNode } from './node-web-bridge.js';
|
|
4
|
+
const PASSTHROUGH_HEADER = 'x-analog-passthrough';
|
|
3
5
|
/**
|
|
4
6
|
* Registers development server middleware by discovering and loading middleware files.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* 4. Handles middleware execution flow and error handling
|
|
8
|
+
* Each discovered h3 middleware module is loaded through Vite's SSR loader,
|
|
9
|
+
* wrapped in a temporary H3 app, then bridged back into Vite's Connect stack.
|
|
10
|
+
* If the middleware does not write a response, control falls through to the
|
|
11
|
+
* next Vite middleware.
|
|
11
12
|
*
|
|
12
13
|
* @param root The project root directory path
|
|
13
14
|
* @param sourceRoot The source directory path (e.g., 'src')
|
|
14
15
|
* @param viteServer The Vite development server instance
|
|
15
|
-
*
|
|
16
|
-
* Example usage:
|
|
17
|
-
* await registerDevServerMiddleware('/workspace/my-app', 'src', viteServer);
|
|
18
|
-
*
|
|
19
|
-
* Sample middleware file paths that would be discovered:
|
|
20
|
-
* - /workspace/my-app/src/server/middleware/auth.ts
|
|
21
|
-
* - /workspace/my-app/src/server/middleware/cors.ts
|
|
22
|
-
* - /workspace/my-app/src/server/middleware/logging.ts
|
|
23
|
-
* - /workspace/my-app/src/server/middleware/validation.ts
|
|
24
|
-
*
|
|
25
|
-
* tinyglobby vs fast-glob comparison:
|
|
26
|
-
* - Both support the same glob patterns for file discovery
|
|
27
|
-
* - Both are efficient for finding middleware files
|
|
28
|
-
* - tinyglobby is now used instead of fast-glob
|
|
29
|
-
* - tinyglobby provides similar functionality with smaller bundle size
|
|
30
|
-
* - tinyglobby's globSync returns absolute paths when absolute: true is set
|
|
31
|
-
*
|
|
32
|
-
* globSync options explained:
|
|
33
|
-
* - dot: true - Includes files/directories that start with a dot (e.g., .env.middleware)
|
|
34
|
-
* - absolute: true - Returns absolute file paths instead of relative paths
|
|
35
|
-
*
|
|
36
|
-
* Middleware execution flow:
|
|
37
|
-
* 1. Request comes to Vite dev server
|
|
38
|
-
* 2. Each registered middleware is executed in order
|
|
39
|
-
* 3. If middleware returns a result, request processing stops
|
|
40
|
-
* 4. If middleware returns no result, next middleware is called
|
|
41
|
-
* 5. If no middleware handles the request, it continues to normal Vite processing
|
|
42
16
|
*/
|
|
43
17
|
export async function registerDevServerMiddleware(root, sourceRoot, viteServer) {
|
|
44
|
-
// Discover all TypeScript middleware files in the server/middleware directory
|
|
45
|
-
// Pattern: looks for any .ts files in server/middleware/**/*.ts
|
|
46
18
|
const middlewareFiles = globSync([`${root}/${sourceRoot}/server/middleware/**/*.ts`], {
|
|
47
19
|
dot: true,
|
|
48
20
|
absolute: true,
|
|
49
21
|
});
|
|
50
|
-
// Register each discovered middleware file with the Vite dev server
|
|
51
22
|
middlewareFiles.forEach((file) => {
|
|
52
23
|
viteServer.middlewares.use(async (req, res, next) => {
|
|
53
|
-
// Dynamically load the middleware module using Vite's SSR module loader
|
|
54
|
-
// This allows for hot module replacement during development
|
|
55
24
|
const middlewareHandler = await viteServer
|
|
56
25
|
.ssrLoadModule(file)
|
|
57
26
|
.then((m) => m.default);
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
|
|
27
|
+
// Bridge h3 event handler using H3.fetch() (web-first API).
|
|
28
|
+
// A sentinel catch-all is appended so that when the middleware
|
|
29
|
+
// returns undefined (does not handle the request), h3 does not
|
|
30
|
+
// emit its default 404 — instead we detect the passthrough
|
|
31
|
+
// header and let the Connect stack continue.
|
|
32
|
+
const app = new H3();
|
|
33
|
+
app.use(middlewareHandler);
|
|
34
|
+
app.use(() => new Response(null, {
|
|
35
|
+
status: 204,
|
|
36
|
+
headers: { [PASSTHROUGH_HEADER]: '1' },
|
|
37
|
+
}));
|
|
38
|
+
const response = await app.fetch(toWebRequest(req));
|
|
39
|
+
if (response.headers.get(PASSTHROUGH_HEADER) === '1') {
|
|
63
40
|
next();
|
|
41
|
+
return;
|
|
64
42
|
}
|
|
43
|
+
await writeWebResponseToNode(res, response);
|
|
65
44
|
});
|
|
66
45
|
});
|
|
67
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-dev-middleware.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-nitro/src/lib/utils/register-dev-middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,
|
|
1
|
+
{"version":3,"file":"register-dev-middleware.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-nitro/src/lib/utils/register-dev-middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,EAAE,EAAE,MAAM,IAAI,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE5E,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,IAAY,EACZ,UAAkB,EAClB,UAAyB;IAEzB,MAAM,eAAe,GAAG,QAAQ,CAC9B,CAAC,GAAG,IAAI,IAAI,UAAU,4BAA4B,CAAC,EACnD;QACE,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,IAAI;KACf,CACF,CAAC;IAEF,eAAe,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/B,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;YAClD,MAAM,iBAAiB,GAAiB,MAAM,UAAU;iBACrD,aAAa,CAAC,IAAI,CAAC;iBACnB,IAAI,CAAC,CAAC,CAAU,EAAE,EAAE,CAAE,CAA+B,CAAC,OAAO,CAAC,CAAC;YAElE,4DAA4D;YAC5D,+DAA+D;YAC/D,+DAA+D;YAC/D,2DAA2D;YAC3D,6CAA6C;YAC7C,MAAM,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC;YACrB,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;YAC3B,GAAG,CAAC,GAAG,CACL,GAAG,EAAE,CACH,IAAI,QAAQ,CAAC,IAAI,EAAE;gBACjB,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE,EAAE,CAAC,kBAAkB,CAAC,EAAE,GAAG,EAAE;aACvC,CAAC,CACL,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;YAEpD,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,KAAK,GAAG,EAAE,CAAC;gBACrD,IAAI,EAAE,CAAC;gBACP,OAAO;YACT,CAAC;YAED,MAAM,sBAAsB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* SSR renderer virtual module content.
|
|
3
|
+
*
|
|
4
|
+
* This code runs inside Nitro's server runtime (Node.js context) where
|
|
5
|
+
* event.node is always populated. In h3 v2, event.node is typed as optional,
|
|
6
|
+
* so we use h3's first-class event properties (event.path, event.method) where
|
|
7
|
+
* possible and apply optional chaining when accessing the Node.js context for
|
|
8
|
+
* the Angular renderer which requires raw req/res objects.
|
|
9
|
+
*
|
|
10
|
+
* h3 v2 idiomatic APIs used:
|
|
11
|
+
* - defineHandler (replaces defineEventHandler / eventHandler)
|
|
12
|
+
* - event.path (replaces event.node.req.url)
|
|
13
|
+
* - getResponseHeader compat shim (still available in h3 v2)
|
|
14
|
+
*/
|
|
15
|
+
export declare function ssrRenderer(templatePath: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Client-only renderer virtual module content.
|
|
18
|
+
*
|
|
19
|
+
* Used when SSR is disabled — simply serves the static index.html template
|
|
20
|
+
* for every route, letting the client-side Angular router handle navigation.
|
|
21
|
+
*/
|
|
22
|
+
export declare function clientRenderer(templatePath: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* API middleware virtual module content.
|
|
25
|
+
*
|
|
26
|
+
* Intercepts requests matching the configured API prefix and either:
|
|
27
|
+
* - Uses event-bound internal forwarding for GET requests (except .xml routes)
|
|
28
|
+
* - Uses request proxying for all other methods to forward the full request
|
|
29
|
+
*
|
|
30
|
+
* h3 v2 idiomatic APIs used:
|
|
31
|
+
* - defineHandler (replaces defineEventHandler / eventHandler)
|
|
32
|
+
* - event.path (replaces event.node.req.url)
|
|
33
|
+
* - event.method (replaces event.node.req.method)
|
|
34
|
+
* - proxyRequest is retained internally because it preserves Nitro route
|
|
35
|
+
* matching for event-bound server requests during SSR/prerender
|
|
36
|
+
* - Object.fromEntries(event.req.headers.entries()) replaces direct event.node.req.headers access
|
|
37
|
+
*
|
|
38
|
+
* `fetchWithEvent` keeps the active event context while forwarding to a
|
|
39
|
+
* rewritten path, which avoids falling through to the HTML renderer when
|
|
40
|
+
* SSR code makes relative API requests.
|
|
41
|
+
*/
|
|
42
|
+
export declare const apiMiddleware = "\nimport { defineHandler, fetchWithEvent, proxyRequest } from 'h3';\nimport { useRuntimeConfig } from 'nitro/runtime-config';\n\nexport default defineHandler(async (event) => {\n const prefix = useRuntimeConfig().prefix;\n const apiPrefix = `${prefix}/${useRuntimeConfig().apiPrefix}`;\n\n if (event.path?.startsWith(apiPrefix)) {\n const reqUrl = event.path?.replace(apiPrefix, '');\n\n if (\n event.method === 'GET' &&\n // in the case of XML routes, we want to proxy the request so that nitro gets the correct headers\n // and can render the XML correctly as a static asset\n !event.path?.endsWith('.xml')\n ) {\n return fetchWithEvent(event, reqUrl, {\n headers: Object.fromEntries(event.req.headers.entries()),\n });\n }\n\n return proxyRequest(event, reqUrl);\n }\n});";
|