rouzer 1.5.1 → 2.0.0
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/server/router.js +1 -1
- package/dist/server/types.d.ts +1 -1
- package/dist/types.d.ts +10 -10
- package/package.json +1 -1
- package/readme.md +3 -3
package/dist/server/router.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RoutePattern } from '@remix-run/route-pattern';
|
|
2
2
|
import { chain, MiddlewareChain, } from 'alien-middleware';
|
|
3
|
-
import * as z from 'zod
|
|
3
|
+
import * as z from 'zod';
|
|
4
4
|
import { mapValues } from '../common.js';
|
|
5
5
|
export { chain };
|
|
6
6
|
// Internal prototype for the router instance.
|
package/dist/server/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Params } from '@remix-run/route-pattern';
|
|
2
2
|
import type { AnyMiddlewareChain, MiddlewareChain, MiddlewareContext } from 'alien-middleware';
|
|
3
|
-
import type * as z from 'zod
|
|
3
|
+
import type * as z from 'zod';
|
|
4
4
|
import { Promisable } from '../common.js';
|
|
5
5
|
import type { InferRouteResponse, Routes, RouteSchema } from '../types.js';
|
|
6
6
|
type RequestContext<TMiddleware extends AnyMiddlewareChain> = MiddlewareContext<TMiddleware>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Params, RoutePattern } from '@remix-run/route-pattern';
|
|
2
|
-
import * as z from 'zod
|
|
2
|
+
import * as z from 'zod';
|
|
3
3
|
import { Unchecked } from './common.js';
|
|
4
4
|
export type { Unchecked };
|
|
5
5
|
export type QueryRouteSchema = {
|
|
6
|
-
path?: z.
|
|
7
|
-
query?: z.
|
|
6
|
+
path?: z.ZodObject<any>;
|
|
7
|
+
query?: z.ZodObject<any>;
|
|
8
8
|
body?: never;
|
|
9
|
-
headers?: z.
|
|
9
|
+
headers?: z.ZodObject<any>;
|
|
10
10
|
response?: Unchecked<any>;
|
|
11
11
|
};
|
|
12
12
|
export type MutationRouteSchema = {
|
|
13
|
-
path?: z.
|
|
13
|
+
path?: z.ZodObject<any>;
|
|
14
14
|
query?: never;
|
|
15
|
-
body?: z.
|
|
16
|
-
headers?: z.
|
|
15
|
+
body?: z.ZodType<any, any>;
|
|
16
|
+
headers?: z.ZodObject<any>;
|
|
17
17
|
response?: Unchecked<any>;
|
|
18
18
|
};
|
|
19
19
|
export type RouteSchemaMap = {
|
|
@@ -23,10 +23,10 @@ export type RouteSchemaMap = {
|
|
|
23
23
|
PATCH?: MutationRouteSchema;
|
|
24
24
|
DELETE?: MutationRouteSchema;
|
|
25
25
|
ALL?: {
|
|
26
|
-
path?: z.
|
|
27
|
-
query?: z.
|
|
26
|
+
path?: z.ZodObject<any>;
|
|
27
|
+
query?: z.ZodObject<any>;
|
|
28
28
|
body?: never;
|
|
29
|
-
headers?: z.
|
|
29
|
+
headers?: z.ZodObject<any>;
|
|
30
30
|
response?: never;
|
|
31
31
|
};
|
|
32
32
|
};
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# rouzer
|
|
2
2
|
|
|
3
|
-
Type-safe routes shared by your server and client, powered by `zod
|
|
3
|
+
Type-safe routes shared by your server and client, powered by `zod` (input validation + transforms), `@remix-run/route-pattern` (URL matching), and `alien-middleware` (typed middleware chaining). The router output is intended to be used with `@hattip/core` adapters.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ Everything is imported directly from `rouzer`.
|
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
// routes.ts
|
|
17
|
-
import * as z from 'zod
|
|
17
|
+
import * as z from 'zod'
|
|
18
18
|
import { $type, route } from 'rouzer'
|
|
19
19
|
|
|
20
20
|
export const helloRoute = route('hello/:name', {
|
|
@@ -171,6 +171,6 @@ const pingText = await pingResponse.text()
|
|
|
171
171
|
|
|
172
172
|
## Add an endpoint
|
|
173
173
|
|
|
174
|
-
1. Declare it in `routes.ts` with `route(…)` and `zod
|
|
174
|
+
1. Declare it in `routes.ts` with `route(…)` and `zod` schemas.
|
|
175
175
|
2. Implement the handler in your router assembly with `createRouter(…).use(routes, { … })`.
|
|
176
176
|
3. Call it from the client with the generated helper via `client.json` or `client.request`.
|