@cedarjs/vite 5.0.0-canary.13898 → 5.0.0-canary.13902
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiDevMiddleware.d.ts","sourceRoot":"","sources":["../src/apiDevMiddleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,MAAM,CAAA;AA2BrD,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,aAAa,iBAe/D;
|
|
1
|
+
{"version":3,"file":"apiDevMiddleware.d.ts","sourceRoot":"","sources":["../src/apiDevMiddleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,MAAM,CAAA;AA2BrD,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,aAAa,iBAe/D;AA8GD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,aAAa,CAAC,CAuElE;AA0BD,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI,CA0EhE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,KAIrB,SAAS,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAoEnD;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC;IACrD,UAAU,EAAE,aAAa,CAAA;IACzB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CACjD,CAAC,CAcD"}
|
package/dist/apiDevMiddleware.js
CHANGED
|
@@ -61,24 +61,33 @@ async function internalLoadApiFunctions(viteServer) {
|
|
|
61
61
|
const routeName = path.basename(fnPath).replace(/\.(ts|tsx|js|jsx)$/, "");
|
|
62
62
|
try {
|
|
63
63
|
const mod = await viteServer.ssrLoadModule(pathToFileURL(fnPath).href);
|
|
64
|
-
const
|
|
64
|
+
const cedarHandler = (() => {
|
|
65
|
+
if ("handleRequest" in mod) {
|
|
66
|
+
return mod.handleRequest;
|
|
67
|
+
}
|
|
68
|
+
if ("default" in mod && mod.default && "handleRequest" in mod.default) {
|
|
69
|
+
return mod.default.handleRequest;
|
|
70
|
+
}
|
|
71
|
+
let legacyHandler;
|
|
65
72
|
if ("handler" in mod) {
|
|
66
|
-
|
|
73
|
+
legacyHandler = mod.handler;
|
|
74
|
+
} else if ("default" in mod && mod.default && "handler" in mod.default) {
|
|
75
|
+
legacyHandler = mod.default.handler;
|
|
67
76
|
}
|
|
68
|
-
if (
|
|
69
|
-
return
|
|
77
|
+
if (legacyHandler) {
|
|
78
|
+
return wrapLegacyHandler(legacyHandler);
|
|
70
79
|
}
|
|
71
80
|
return void 0;
|
|
72
81
|
})();
|
|
73
|
-
if (
|
|
74
|
-
LAMBDA_FUNCTIONS[routeName] =
|
|
82
|
+
if (cedarHandler) {
|
|
83
|
+
LAMBDA_FUNCTIONS[routeName] = cedarHandler;
|
|
75
84
|
console.log(
|
|
76
85
|
ansis.magenta("/" + routeName),
|
|
77
86
|
ansis.dim.italic(Date.now() - ts + " ms")
|
|
78
87
|
);
|
|
79
88
|
} else {
|
|
80
89
|
console.warn(
|
|
81
|
-
`[apiDevMiddleware] No handler export found in function: ${fnPath}`
|
|
90
|
+
`[apiDevMiddleware] No handler or handleRequest export found in function: ${fnPath}`
|
|
82
91
|
);
|
|
83
92
|
}
|
|
84
93
|
if (routeName === "graphql" && "__rw_graphqlOptions" in mod) {
|
|
@@ -279,8 +288,7 @@ function createApiFetchHandler() {
|
|
|
279
288
|
const ctx = await buildCedarContext(request, {
|
|
280
289
|
params: { routeName }
|
|
281
290
|
});
|
|
282
|
-
|
|
283
|
-
return await cedarHandler(request, ctx);
|
|
291
|
+
return await handler(request, ctx);
|
|
284
292
|
} catch (err) {
|
|
285
293
|
console.error(
|
|
286
294
|
`[apiDevMiddleware] Error handling function "${routeName}":`,
|
|
@@ -95,24 +95,33 @@ async function internalLoadApiFunctions(viteServer) {
|
|
|
95
95
|
const routeName = import_node_path.default.basename(fnPath).replace(/\.(ts|tsx|js|jsx)$/, "");
|
|
96
96
|
try {
|
|
97
97
|
const mod = await viteServer.ssrLoadModule((0, import_node_url.pathToFileURL)(fnPath).href);
|
|
98
|
-
const
|
|
98
|
+
const cedarHandler = (() => {
|
|
99
|
+
if ("handleRequest" in mod) {
|
|
100
|
+
return mod.handleRequest;
|
|
101
|
+
}
|
|
102
|
+
if ("default" in mod && mod.default && "handleRequest" in mod.default) {
|
|
103
|
+
return mod.default.handleRequest;
|
|
104
|
+
}
|
|
105
|
+
let legacyHandler;
|
|
99
106
|
if ("handler" in mod) {
|
|
100
|
-
|
|
107
|
+
legacyHandler = mod.handler;
|
|
108
|
+
} else if ("default" in mod && mod.default && "handler" in mod.default) {
|
|
109
|
+
legacyHandler = mod.default.handler;
|
|
101
110
|
}
|
|
102
|
-
if (
|
|
103
|
-
return
|
|
111
|
+
if (legacyHandler) {
|
|
112
|
+
return (0, import_runtime.wrapLegacyHandler)(legacyHandler);
|
|
104
113
|
}
|
|
105
114
|
return void 0;
|
|
106
115
|
})();
|
|
107
|
-
if (
|
|
108
|
-
LAMBDA_FUNCTIONS[routeName] =
|
|
116
|
+
if (cedarHandler) {
|
|
117
|
+
LAMBDA_FUNCTIONS[routeName] = cedarHandler;
|
|
109
118
|
console.log(
|
|
110
119
|
import_ansis.default.magenta("/" + routeName),
|
|
111
120
|
import_ansis.default.dim.italic(Date.now() - ts + " ms")
|
|
112
121
|
);
|
|
113
122
|
} else {
|
|
114
123
|
console.warn(
|
|
115
|
-
`[apiDevMiddleware] No handler export found in function: ${fnPath}`
|
|
124
|
+
`[apiDevMiddleware] No handler or handleRequest export found in function: ${fnPath}`
|
|
116
125
|
);
|
|
117
126
|
}
|
|
118
127
|
if (routeName === "graphql" && "__rw_graphqlOptions" in mod) {
|
|
@@ -313,8 +322,7 @@ function createApiFetchHandler() {
|
|
|
313
322
|
const ctx = await (0, import_runtime.buildCedarContext)(request, {
|
|
314
323
|
params: { routeName }
|
|
315
324
|
});
|
|
316
|
-
|
|
317
|
-
return await cedarHandler(request, ctx);
|
|
325
|
+
return await handler(request, ctx);
|
|
318
326
|
} catch (err) {
|
|
319
327
|
console.error(
|
|
320
328
|
`[apiDevMiddleware] Error handling function "${routeName}":`,
|
|
@@ -22,17 +22,22 @@ __export(function_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(function_exports);
|
|
24
24
|
var import_node_url = require("node:url");
|
|
25
|
+
var import_runtime = require("@cedarjs/api/runtime");
|
|
25
26
|
var import_udFetchable = require("@cedarjs/api-server/udFetchable");
|
|
26
27
|
function createFunctionHandler(options) {
|
|
27
28
|
const handleRequest = async (request, ctx) => {
|
|
28
29
|
const mod = await import((0, import_node_url.pathToFileURL)(options.distPath).href);
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
`Fetch-native handler not found in ${options.distPath}. Expected \`export async function handleRequest(request, ctx)\` or \`export default { handleRequest }\`.`
|
|
33
|
-
);
|
|
30
|
+
const nativeHandler = mod.handleRequest || mod.default?.handleRequest;
|
|
31
|
+
if (nativeHandler) {
|
|
32
|
+
return nativeHandler(request, ctx);
|
|
34
33
|
}
|
|
35
|
-
|
|
34
|
+
const legacyHandler = mod.handler || mod.default?.handler;
|
|
35
|
+
if (legacyHandler) {
|
|
36
|
+
return (0, import_runtime.wrapLegacyHandler)(legacyHandler)(request, ctx);
|
|
37
|
+
}
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Handler not found in ${options.distPath}. Expected \`export async function handleRequest(request, ctx)\`, \`export default { handleRequest }\`, or a legacy Lambda-shaped \`handler\`.`
|
|
40
|
+
);
|
|
36
41
|
};
|
|
37
42
|
return (0, import_udFetchable.createCedarFetchable)(handleRequest);
|
|
38
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/ud-handlers/function.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/ud-handlers/function.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,uDAyBpE"}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { pathToFileURL } from "node:url";
|
|
2
|
+
import { wrapLegacyHandler } from "@cedarjs/api/runtime";
|
|
2
3
|
import { createCedarFetchable } from "@cedarjs/api-server/udFetchable";
|
|
3
4
|
function createFunctionHandler(options) {
|
|
4
5
|
const handleRequest = async (request, ctx) => {
|
|
5
6
|
const mod = await import(pathToFileURL(options.distPath).href);
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
`Fetch-native handler not found in ${options.distPath}. Expected \`export async function handleRequest(request, ctx)\` or \`export default { handleRequest }\`.`
|
|
10
|
-
);
|
|
7
|
+
const nativeHandler = mod.handleRequest || mod.default?.handleRequest;
|
|
8
|
+
if (nativeHandler) {
|
|
9
|
+
return nativeHandler(request, ctx);
|
|
11
10
|
}
|
|
12
|
-
|
|
11
|
+
const legacyHandler = mod.handler || mod.default?.handler;
|
|
12
|
+
if (legacyHandler) {
|
|
13
|
+
return wrapLegacyHandler(legacyHandler)(request, ctx);
|
|
14
|
+
}
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Handler not found in ${options.distPath}. Expected \`export async function handleRequest(request, ctx)\`, \`export default { handleRequest }\`, or a legacy Lambda-shaped \`handler\`.`
|
|
17
|
+
);
|
|
13
18
|
};
|
|
14
19
|
return createCedarFetchable(handleRequest);
|
|
15
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/vite",
|
|
3
|
-
"version": "5.0.0-canary.
|
|
3
|
+
"version": "5.0.0-canary.13902+61d1e11811",
|
|
4
4
|
"description": "Vite configuration package for CedarJS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -99,18 +99,18 @@
|
|
|
99
99
|
"@babel/generator": "7.29.1",
|
|
100
100
|
"@babel/parser": "7.29.2",
|
|
101
101
|
"@babel/traverse": "7.29.0",
|
|
102
|
-
"@cedarjs/api": "5.0.0-canary.
|
|
103
|
-
"@cedarjs/api-server": "5.0.0-canary.
|
|
104
|
-
"@cedarjs/auth": "5.0.0-canary.
|
|
105
|
-
"@cedarjs/babel-config": "5.0.0-canary.
|
|
106
|
-
"@cedarjs/context": "5.0.0-canary.
|
|
107
|
-
"@cedarjs/cookie-jar": "5.0.0-canary.
|
|
108
|
-
"@cedarjs/graphql-server": "5.0.0-canary.
|
|
109
|
-
"@cedarjs/internal": "5.0.0-canary.
|
|
110
|
-
"@cedarjs/project-config": "5.0.0-canary.
|
|
111
|
-
"@cedarjs/server-store": "5.0.0-canary.
|
|
112
|
-
"@cedarjs/testing": "5.0.0-canary.
|
|
113
|
-
"@cedarjs/web": "5.0.0-canary.
|
|
102
|
+
"@cedarjs/api": "5.0.0-canary.13902",
|
|
103
|
+
"@cedarjs/api-server": "5.0.0-canary.13902",
|
|
104
|
+
"@cedarjs/auth": "5.0.0-canary.13902",
|
|
105
|
+
"@cedarjs/babel-config": "5.0.0-canary.13902",
|
|
106
|
+
"@cedarjs/context": "5.0.0-canary.13902",
|
|
107
|
+
"@cedarjs/cookie-jar": "5.0.0-canary.13902",
|
|
108
|
+
"@cedarjs/graphql-server": "5.0.0-canary.13902",
|
|
109
|
+
"@cedarjs/internal": "5.0.0-canary.13902",
|
|
110
|
+
"@cedarjs/project-config": "5.0.0-canary.13902",
|
|
111
|
+
"@cedarjs/server-store": "5.0.0-canary.13902",
|
|
112
|
+
"@cedarjs/testing": "5.0.0-canary.13902",
|
|
113
|
+
"@cedarjs/web": "5.0.0-canary.13902",
|
|
114
114
|
"@fastify/url-data": "6.0.3",
|
|
115
115
|
"@swc/core": "1.15.32",
|
|
116
116
|
"@universal-deploy/node": "^0.1.6",
|
|
@@ -166,5 +166,5 @@
|
|
|
166
166
|
"publishConfig": {
|
|
167
167
|
"access": "public"
|
|
168
168
|
},
|
|
169
|
-
"gitHead": "
|
|
169
|
+
"gitHead": "61d1e11811bdc624db5b3aab49346430cfc963bc"
|
|
170
170
|
}
|