@openworkers/adapter-sveltekit 0.5.4 → 0.5.5
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/dist/index.d.ts +2 -0
- package/dist/index.js +3 -2
- package/dist/runtime/function-worker.js +9 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -101240,9 +101240,9 @@ export function extractParams(url) {
|
|
|
101240
101240
|
// src/adapter/build-function.ts
|
|
101241
101241
|
async function buildFunctionWorker(options8) {
|
|
101242
101242
|
const { endpointFile, outfile, routePattern, minify = false, debug = {}, hooksFile } = options8;
|
|
101243
|
-
const usesCookies = detectCookiesUsage(endpointFile);
|
|
101244
101243
|
const usesLocals = detectLocalsUsage(endpointFile);
|
|
101245
101244
|
const withHooks = usesLocals && !!hooksFile;
|
|
101245
|
+
const usesCookies = detectCookiesUsage(endpointFile) || withHooks && detectCookiesUsage(hooksFile);
|
|
101246
101246
|
const hasParams = routePattern.includes("[");
|
|
101247
101247
|
const tempDir = mkdtempSync(path15.join(tmpdir(), "adapter-params-"));
|
|
101248
101248
|
const paramsModulePath = path15.join(tempDir, "params.js");
|
|
@@ -101286,7 +101286,8 @@ async function buildFunctionWorker(options8) {
|
|
|
101286
101286
|
ROUTE_PATTERN: JSON.stringify(routePattern),
|
|
101287
101287
|
WITH_COOKIES: JSON.stringify(usesCookies),
|
|
101288
101288
|
WITH_PARAMS: JSON.stringify(hasParams),
|
|
101289
|
-
WITH_HOOKS: JSON.stringify(withHooks)
|
|
101289
|
+
WITH_HOOKS: JSON.stringify(withHooks),
|
|
101290
|
+
DEBUG_ERRORS: JSON.stringify(debug.errors ?? false)
|
|
101290
101291
|
}
|
|
101291
101292
|
});
|
|
101292
101293
|
if (debug.prettier) {
|
|
@@ -83,13 +83,15 @@ var worker = {
|
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
console.error(`[Function] Error in ${method} handler:`, error);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
const body = { error: "Internal Server Error" };
|
|
87
|
+
if (DEBUG_ERRORS) {
|
|
88
|
+
body.details = error?.message ?? String(error);
|
|
89
|
+
body.stack = error?.stack ?? "";
|
|
90
|
+
}
|
|
91
|
+
return Response.json(body, {
|
|
92
|
+
status: 500,
|
|
93
|
+
headers: { "Content-Type": "application/json" }
|
|
94
|
+
});
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
};
|