@efebia/fastify-zod-reply 1.0.5 → 1.0.7

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/lib/cjs/reply.js CHANGED
@@ -7,7 +7,8 @@ const createReply = (statusCode, defaultPayload) => {
7
7
  const finalPayload = payload !== null && payload !== void 0 ? payload : defaultPayload;
8
8
  if (typeof finalPayload === 'string')
9
9
  throw (0, exports.createError)(statusCode)(finalPayload);
10
- this.type("application/json");
10
+ if (typeof finalPayload !== 'undefined')
11
+ this.type("application/json");
11
12
  this.code(statusCode);
12
13
  return finalPayload;
13
14
  };
@@ -2,7 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.routeV4 = void 0;
4
4
  const v4_1 = require("zod/v4");
5
- const mapZodError = (zodError, prefix) => zodError.issues.map(issue => `Error at ${prefix}->${issue.path.join('->')}`).join(';\n');
5
+ const mapZodError = (zodError, prefix) => {
6
+ return zodError.issues.map(issue => {
7
+ const pathStr = `Error at ${prefix}->${issue.path.join('->')}`;
8
+ return issue.message ? `${pathStr}->${issue.message}` : pathStr;
9
+ }).join('\n');
10
+ };
6
11
  const parse = async (schema, payload, tag) => {
7
12
  const result = await schema.safeParseAsync(payload);
8
13
  return Object.assign(Object.assign({}, result), { tag });
package/lib/esm/reply.js CHANGED
@@ -4,7 +4,8 @@ export const createReply = (statusCode, defaultPayload) => {
4
4
  const finalPayload = payload !== null && payload !== void 0 ? payload : defaultPayload;
5
5
  if (typeof finalPayload === 'string')
6
6
  throw createError(statusCode)(finalPayload);
7
- this.type("application/json");
7
+ if (typeof finalPayload !== 'undefined')
8
+ this.type("application/json");
8
9
  this.code(statusCode);
9
10
  return finalPayload;
10
11
  };
@@ -1,5 +1,10 @@
1
1
  import { z } from 'zod/v4';
2
- const mapZodError = (zodError, prefix) => zodError.issues.map(issue => `Error at ${prefix}->${issue.path.join('->')}`).join(';\n');
2
+ const mapZodError = (zodError, prefix) => {
3
+ return zodError.issues.map(issue => {
4
+ const pathStr = `Error at ${prefix}->${issue.path.join('->')}`;
5
+ return issue.message ? `${pathStr}->${issue.message}` : pathStr;
6
+ }).join('\n');
7
+ };
3
8
  const parse = async (schema, payload, tag) => {
4
9
  const result = await schema.safeParseAsync(payload);
5
10
  return Object.assign(Object.assign({}, result), { tag });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efebia/fastify-zod-reply",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
6
  "fastify": "^5.3.0",
@@ -12,14 +12,16 @@
12
12
  "/lib"
13
13
  ],
14
14
  "scripts": {
15
- "build:esm": "tsc --module nodenext --moduleResolution nodenext --outDir lib/esm",
16
- "build:cjs": "tsc --module commonjs --moduleResolution node --outDir lib/cjs",
17
- "build": "yarn build:esm && yarn build:cjs"
15
+ "build:esm": "tsc -p ./tsconfig.build.json --module nodenext --moduleResolution nodenext --outDir lib/esm",
16
+ "build:cjs": "tsc -p ./tsconfig.build.json --module commonjs --moduleResolution node --outDir lib/cjs",
17
+ "build": "yarn build:esm && yarn build:cjs",
18
+ "test": "node --import tsx --test ./**/*.test.ts"
18
19
  },
19
20
  "main": "./lib/esm/index.js",
20
21
  "types": "./lib/esm/index.d.ts",
21
22
  "type": "module",
22
23
  "devDependencies": {
24
+ "tsx": "^4.20.3",
23
25
  "typescript": "~5.8.3"
24
26
  },
25
27
  "exports": {