Skip to content

Commit d2448c3

Browse files
authored
Merge branch 'master' into feat-method-head
2 parents 16e0520 + 7c344fc commit d2448c3

File tree

7 files changed

+116
-76
lines changed

7 files changed

+116
-76
lines changed

CHANGELOG.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,32 @@
22

33
## Version 24
44

5+
### v24.6.2
6+
7+
- Correcting recommendations given in [v24.6.0](#v2460) regarding using with `zod@^4.0.0`:
8+
- Make sure the `moduleResolution` in your `tsconfig.json` is either `node16`, `nodenext` or `bundler`;
9+
- Consider the [recommended tsconfig base, Node 20+](https://github.com/tsconfig/bases/blob/main/bases/node20.json);
10+
- Then you MAY `import { z } from "zod"`;
11+
- Otherwise, you MUST keep `import { z } from "zod/v4"`;
12+
- In some cases module augmentation (Zod plugin) did not work and caused schema assignment errors for some users;
13+
- The issue was reported by [@MichaelHindley](https://github.com/MichaelHindley);
14+
- This potential inconvenience will be resolved by dropping `zod@^3` in the next version of Express Zod API:
15+
- If you're having troubles using the framework with `zod@^4.0.0`, consider upgrading to v25 (currently beta).
16+
17+
### v24.6.1
18+
19+
- Compatibility fix for recently changed type of Express native middleware:
20+
- Fixes error `TS2345` when passing over an Express middleware to:
21+
- `EndpointsFactory::use()`;
22+
- `EndpointsFactory::addExpressMiddleware()`;
23+
- The issue caused by `@types/express-serve-static-core` v5.0.7;
24+
- The issue reported by [@zoton2](https://github.com/zoton2).
25+
526
### v24.6.0
627

728
- Supporting `zod` versions `^3.25.35 || ^4.0.0`:
8-
- If you use `zod@^4.0.0` then `import { z } from "zod"`;
29+
- If you use `zod@^4.0.0` then you MAY `import { z } from "zod"`:
30+
- If facing error, ensure `moduleResolution` in your `tsconfig.json` is either `node16`, `nodenext` or `bundler`;
931
- If you use `zod@^3.25.35` then keep `import { z } from "zod/v4"`;
1032
- For more details, see the [Explanation of the versioning strategy](https://github.com/colinhacks/zod/issues/4371).
1133

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Start your API server with I/O schema validation and custom middlewares in minut
5858
5. [Graceful shutdown](#graceful-shutdown)
5959
6. [Subscriptions](#subscriptions)
6060
8. [Caveats](#caveats)
61-
1. [Excessive properties in endpoint output](#excessive-properties-in-endpoint-output)
61+
1. [Zod 4 schema assignment error](#zod-4-schema-assignment-error)
62+
2. [Excessive properties in endpoint output](#excessive-properties-in-endpoint-output)
6263
9. [Your input to my output](#your-input-to-my-output)
6364

6465
See also [Changelog](CHANGELOG.md) and [automated migration](https://www.npmjs.com/package/@express-zod-api/migration).
@@ -84,6 +85,8 @@ Therefore, many basic tasks can be accomplished faster and easier, in particular
8485

8586
These people contributed to the improvement of the framework by reporting bugs, making changes and suggesting ideas:
8687

88+
[<img src="https://github.com/MichaelHindley.png" alt="@MichaelHindley" width="50px" />](https://github.com/MichaelHindley)
89+
[<img src="https://github.com/zoton2.png" alt="@zoton2" width="50px" />](https://github.com/zoton2)
8790
[<img src="https://github.com/ThomasKientz.png" alt="@ThomasKientz" width="50px" />](https://github.com/ThomasKientz)
8891
[<img src="https://github.com/james10424.png" alt="@james10424" width="50px" />](https://github.com/james10424)
8992
[<img src="https://github.com/HeikoOsigus.png" alt="@HeikoOsigus" width="50px" />](https://github.com/HeikoOsigus)
@@ -174,7 +177,11 @@ pnpm add express-zod-api express zod typescript http-errors
174177
pnpm add -D @types/express @types/node @types/http-errors
175178
```
176179

177-
Ensure having the following options in your `tsconfig.json` file in order to make it work as expected:
180+
## Environment preparation
181+
182+
Consider using the recommended `tsconfig.json` base for your project according to your Node.js version,
183+
for example [the base for Node.js 20+](https://github.com/tsconfig/bases/blob/main/bases/node20.json).
184+
Ensure having the following options in order to make it work as expected:
178185

179186
```json
180187
{
@@ -185,6 +192,8 @@ Ensure having the following options in your `tsconfig.json` file in order to mak
185192
}
186193
```
187194

195+
See also how `moduleResolution` may cause [Zod 4 schema assignment error](#zod-4-schema-assignment-error).
196+
188197
## Set up config
189198

190199
Create a minimal configuration. Find out all configurable options
@@ -1376,6 +1385,18 @@ framework, [Zod Sockets](https://github.com/RobinTail/zod-sockets), which has si
13761385
There are some well-known issues and limitations, or third party bugs that cannot be fixed in the usual way, but you
13771386
should be aware of them.
13781387

1388+
## Zod 4 schema assignment error
1389+
1390+
When using `zod@^4` and doing `import { z } from "zod"` you may encounter the following error:
1391+
1392+
```text
1393+
TS2739: ZodObject<...> is missing the following properties from ZodType<...>: example, deprecated.
1394+
```
1395+
1396+
In this case make sure the `moduleResolution` in your `tsconfig.json` is either `node16`, `nodenext` or `bundler`.
1397+
Consider the [recommended tsconfig base, Node 20+](https://github.com/tsconfig/bases/blob/main/bases/node20.json).
1398+
Otherwise, keep importing `from "zod/v4"` or consider upgrading the framework to v25.
1399+
13791400
## Excessive properties in endpoint output
13801401

13811402
The schema validator removes excessive properties by default. However, Typescript

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| 23.x.x | Sonia | 04.2025 | :white_check_mark: |
99
| 22.x.x | Tai | 01.2025 | :white_check_mark: |
1010
| 21.x.x | Kesaria | 11.2024 | :white_check_mark: |
11-
| 20.x.x | Zoey | 06.2024 | :white_check_mark: |
11+
| 20.x.x | Zoey | 06.2024 | :x: |
1212
| 19.x.x | Dime | 05.2024 | :x: |
1313
| 18.x.x | Victoria | 04.2024 | :x: |
1414
| 17.x.x | Tonya | 02.2024 | :x: |

express-zod-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "express-zod-api",
3-
"version": "24.6.0",
3+
"version": "24.6.2",
44
"description": "A Typescript framework to help you get an API server up and running with I/O schema validation and custom middlewares in minutes.",
55
"license": "MIT",
66
"repository": {

express-zod-api/src/config-type.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export interface ServerConfig extends CommonConfig {
159159
/**
160160
* @desc Custom JSON parser.
161161
* @default express.json()
162-
* @link https://expressjs.com/en/4x/api.html#express.json
162+
* @link https://expressjs.com/en/5x/api.html#express.json
163163
* */
164164
jsonParser?: RequestHandler;
165165
/**
@@ -175,13 +175,13 @@ export interface ServerConfig extends CommonConfig {
175175
/**
176176
* @desc Custom raw parser (assigns Buffer to request body)
177177
* @default express.raw()
178-
* @link https://expressjs.com/en/4x/api.html#express.raw
178+
* @link https://expressjs.com/en/5x/api.html#express.raw
179179
* */
180180
rawParser?: RequestHandler;
181181
/**
182182
* @desc Custom parser for URL Encoded requests used for submitting HTML forms
183183
* @default express.urlencoded()
184-
* @link https://expressjs.com/en/4x/api.html#express.urlencoded
184+
* @link https://expressjs.com/en/5x/api.html#express.urlencoded
185185
* */
186186
formParser?: RequestHandler;
187187
/**

express-zod-api/src/middleware.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,8 @@ export class ExpressMiddleware<
109109
OUT extends FlatObject,
110110
> extends Middleware<FlatObject, OUT, string> {
111111
constructor(
112-
nativeMw: (
113-
request: R,
114-
response: S,
115-
next: NextFunction,
116-
) => void | Promise<void>,
112+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- issue #2824, assignment compatibility fix
113+
nativeMw: (request: R, response: S, next: NextFunction) => any,
117114
{
118115
provider = () => ({}) as OUT,
119116
transformer = (err: Error) => err,

0 commit comments

Comments
 (0)