@server/next 0.20.23 → 0.20.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@server/next",
3
- "version": "0.20.23",
3
+ "version": "0.20.25",
4
4
  "description": "An experimental reimplementation of server.js focused on the DX",
5
5
  "homepage": "https://node-server.com/",
6
6
  "repository": "https://github.com/franciscop/server-next.git",
@@ -6,10 +6,11 @@ export default new Proxy(NoSession, {
6
6
  get(target, key) {
7
7
  if (target[key]) return target[key];
8
8
  if (key === "then") return target[key];
9
+ if (typeof key === "symbol") return target[key];
9
10
  throw ServerError.NO_STORE_READ({ key });
10
11
  },
11
12
  set(target, key, value) {
12
- if (target[key] || key === "then") {
13
+ if (target[key] || key === "then" || typeof key === "symbol") {
13
14
  target[key] = value;
14
15
  } else {
15
16
  throw ServerError.NO_STORE_WRITE({ key });
@@ -12,11 +12,12 @@ export default async function handleRequest(handlers, ctx) {
12
12
  define(ctx.url, "params", () => match);
13
13
 
14
14
  for (let cb of cbs) {
15
- validate(ctx, cb);
16
15
  if (typeof cb === "function") {
17
16
  const res = await cb(ctx);
18
17
  const out = await parseResponse(res, ctx);
19
18
  if (out) return out;
19
+ } else {
20
+ validate(ctx, cb);
20
21
  }
21
22
  }
22
23
 
@@ -1,6 +1,6 @@
1
1
  import StatusError from "./StatusError.js";
2
2
 
3
- export default function (ctx, schema) {
3
+ export default function validate(ctx, schema) {
4
4
  if (!schema || typeof schema !== "object") return;
5
5
 
6
6
  let base;
@@ -22,7 +22,7 @@ export default function (ctx, schema) {
22
22
  schema.query.parse(ctx.url.query || {});
23
23
  }
24
24
  } catch (error) {
25
- if (error.constructor.name === "ZodError") {
25
+ if (error.name === "ZodError" || error.constructor.name === "ZodError") {
26
26
  const message = error.issues
27
27
  .map(({ path, message }) => `[${base}.${path.join(".")}]: ${message}`)
28
28
  .sort()
package/src/index.js CHANGED
@@ -176,7 +176,6 @@ export default function server(options = {}) {
176
176
  extendWithDefaults(ctx);
177
177
  return await handleRequest(this.handlers, ctx);
178
178
  } catch (error) {
179
- console.error(error);
180
179
  return new Response(error.message, { status: error.status || 500 });
181
180
  }
182
181
  };