@rest-rpc/next 0.1.0-beta.13 → 0.1.0-beta.14
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 +1 -1
- package/dist/server.d.ts +21 -3
- package/dist/server.js +2 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { type ClearCookieOptions, clearCookie, type RouteErrors, type RouteRequestData, RouteResponseError, type RouteResponseShorthand, type SetCookieOptions, setCookie, } from "@rest-rpc/web";
|
|
2
|
-
export { type CreateRouteHandlerOptions, createRouteHandler, type NextRouteMiddleware, type RouteRequest, type RouteResponse, route, router, } from "./server.ts";
|
|
2
|
+
export { type CreateRouteHandlerOptions, createRouteHandler, type NextRouteMiddleware, type RouteHandlers, type RouteRequest, type RouteResponse, route, router, } from "./server.ts";
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpRouteDeclaration } from "@rest-rpc/core/contract";
|
|
2
|
-
import { type CreateWebHandlerOptions, type WebContract, type WebImplementationTree, type WebRouteBuilder, type WebRouteMiddleware, type WebRouteParseBodyInput, type RouteRequest as WebRouteRequest, type RouteResponse as WebRouteResponse, type WebRouterBuilder } from "@rest-rpc/web";
|
|
2
|
+
import { type CreateWebHandlerOptions, type WebContract, type WebImplementationTree, type WebRouteBuilder, type RouteHandlers as WebRouteHandlers, type WebRouteMiddleware, type WebRouteParseBodyInput, type RouteRequest as WebRouteRequest, type RouteResponse as WebRouteResponse, type WebRouterBuilder } from "@rest-rpc/web";
|
|
3
3
|
import type { NextRequest } from "next/server.js";
|
|
4
4
|
/**
|
|
5
5
|
* Middleware function shape for Next.js route handlers.
|
|
@@ -19,6 +19,24 @@ export type RouteRequest<E extends HttpRouteDeclaration, TContext extends Record
|
|
|
19
19
|
* @see {@link https://rest-rpc.dev/docs/type-helpers#server}
|
|
20
20
|
*/
|
|
21
21
|
export type RouteResponse<E extends HttpRouteDeclaration> = WebRouteResponse<E>;
|
|
22
|
+
/**
|
|
23
|
+
* Handler tree accepted by `router().handlers()` when building a Next.js implementation tree.
|
|
24
|
+
*
|
|
25
|
+
* @remarks Use this type with `implements` to check class-based route handler
|
|
26
|
+
* services against a contract tree.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* class TodoHandlers implements RouteHandlers<typeof api.todos> {
|
|
31
|
+
* get(request: RouteRequest<typeof api.todos.get>) {
|
|
32
|
+
* return { id: request.id };
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @see {@link https://rest-rpc.dev/docs/recipes/class-handlers}
|
|
38
|
+
*/
|
|
39
|
+
export type RouteHandlers<TContract extends WebContract, TContext extends Record<string, unknown> = Record<string, unknown>> = WebRouteHandlers<TContract, TContext, NextRequest>;
|
|
22
40
|
/**
|
|
23
41
|
* Options for creating Next.js route handler exports.
|
|
24
42
|
*
|
|
@@ -29,13 +47,13 @@ export type CreateRouteHandlerOptions = {
|
|
|
29
47
|
parseBody?: (input: WebRouteParseBodyInput) => unknown | Promise<unknown>;
|
|
30
48
|
};
|
|
31
49
|
/**
|
|
32
|
-
* Creates a
|
|
50
|
+
* Creates a Next.js route implementation builder for a single HTTP route.
|
|
33
51
|
*
|
|
34
52
|
* @see {@link https://rest-rpc.dev/docs/server/next.js#single-route-handler}
|
|
35
53
|
*/
|
|
36
54
|
export declare function route<const TRoute extends HttpRouteDeclaration>(contract: TRoute): WebRouteBuilder<TRoute, Record<never, never>, NextRequest>;
|
|
37
55
|
/**
|
|
38
|
-
* Creates a
|
|
56
|
+
* Creates a Next.js router implementation builder for a contract tree.
|
|
39
57
|
*
|
|
40
58
|
* @see {@link https://rest-rpc.dev/docs/server/next.js#catch-all-route-handler}
|
|
41
59
|
*/
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRouteHandler as createWebRouteHandler, route as webRoute, router as webRouter, } from "@rest-rpc/web";
|
|
2
2
|
/**
|
|
3
|
-
* Creates a
|
|
3
|
+
* Creates a Next.js route implementation builder for a single HTTP route.
|
|
4
4
|
*
|
|
5
5
|
* @see {@link https://rest-rpc.dev/docs/server/next.js#single-route-handler}
|
|
6
6
|
*/
|
|
@@ -8,7 +8,7 @@ export function route(contract) {
|
|
|
8
8
|
return webRoute(contract);
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Creates a
|
|
11
|
+
* Creates a Next.js router implementation builder for a contract tree.
|
|
12
12
|
*
|
|
13
13
|
* @see {@link https://rest-rpc.dev/docs/server/next.js#catch-all-route-handler}
|
|
14
14
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rest-rpc/next",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Next.js adapter for serving and consuming rest-rpc contracts in App Router projects.",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"directory": "test-d"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@rest-rpc/
|
|
44
|
-
"@rest-rpc/
|
|
43
|
+
"@rest-rpc/web": "0.1.0-beta.14",
|
|
44
|
+
"@rest-rpc/core": "0.1.0-beta.14"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"next": ">=15"
|