@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 CHANGED
@@ -29,6 +29,8 @@ export interface AdapterOptions {
29
29
  sourcemap?: boolean;
30
30
  /** Format output with Prettier for readability */
31
31
  prettier?: boolean;
32
+ /** Include error details and stack traces in 500 responses */
33
+ errors?: boolean;
32
34
  };
33
35
  }
34
36
 
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
- return Response.json(
87
- { error: "Internal Server Error" },
88
- {
89
- status: 500,
90
- headers: { "Content-Type": "application/json" }
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openworkers/adapter-sveltekit",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "SvelteKit adapter for OpenWorkers",
5
5
  "keywords": [
6
6
  "adapter",