@kizunajs/next 2.0.0-beta.4 → 2.0.0-beta.40
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.cjs +66 -18
- package/dist/index.d.cts +4 -2
- package/dist/index.d.mts +4 -2
- package/dist/index.mjs +68 -20
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -6,10 +6,32 @@ const jsonResponse = (status, body, headers, raw = false) => new next_server_js.
|
|
|
6
6
|
status,
|
|
7
7
|
headers
|
|
8
8
|
});
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* The GET a method-override POST stands in for: its form body appended to the
|
|
11
|
+
* URL's query, so the GET route reads it as it reads any query.
|
|
12
|
+
*/
|
|
13
|
+
const asGetRequest = async (request) => {
|
|
14
|
+
const url = new URL(request.url);
|
|
15
|
+
for (const [key, value] of new URLSearchParams(await request.text())) url.searchParams.append(key, value);
|
|
16
|
+
const headers = new Headers(request.headers);
|
|
17
|
+
headers.delete("content-type");
|
|
18
|
+
headers.delete("content-length");
|
|
19
|
+
headers.delete(kizunajs_adapter.METHOD_OVERRIDE_HEADER);
|
|
20
|
+
return new next_server_js.NextRequest(url, {
|
|
21
|
+
method: "GET",
|
|
22
|
+
headers,
|
|
23
|
+
signal: request.signal
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const handleNextRequest = async (request, routes, router, options, guards, schemes, requestContext, pluginExports, jobs, configBodyLimit, configNestingLimit) => {
|
|
10
27
|
const url = new URL(request.url);
|
|
11
|
-
const adapter = (0, kizunajs_adapter.
|
|
28
|
+
const adapter = (0, kizunajs_adapter.defineAdapter)({
|
|
12
29
|
buildHandlerContext: (adapterRequest) => ({ request: adapterRequest.request }),
|
|
30
|
+
waitUntil: (promise) => {
|
|
31
|
+
try {
|
|
32
|
+
(0, next_server_js.after)(promise);
|
|
33
|
+
} catch {}
|
|
34
|
+
},
|
|
13
35
|
respond: (result) => {
|
|
14
36
|
if (result.kind === "raw-response") return result.response;
|
|
15
37
|
const rendered = (0, kizunajs_adapter.renderJsonResult)(result, options?.formatError, request, request.method);
|
|
@@ -46,9 +68,12 @@ const handleNextRequest = async (request, routes, router, options, guards, schem
|
|
|
46
68
|
route: matchedJob.match.route,
|
|
47
69
|
params: matchedJob.match.params
|
|
48
70
|
},
|
|
49
|
-
query:
|
|
71
|
+
query: (0, kizunajs_adapter.entriesToObject)(url.searchParams),
|
|
50
72
|
headers: (0, kizunajs_adapter.headersToObject)(request.headers),
|
|
51
|
-
readBody: (route) => (0, kizunajs_adapter.parseFetchBody)(request, route)
|
|
73
|
+
readBody: (route) => (0, kizunajs_adapter.parseFetchBody)(request, route, (0, kizunajs_adapter.bodyLimitOf)(route, configBodyLimit)),
|
|
74
|
+
readRawBody: (route) => (0, kizunajs_adapter.readBodyText)(request, (0, kizunajs_adapter.bodyLimitOf)(route, configBodyLimit)),
|
|
75
|
+
configBodyLimit,
|
|
76
|
+
configNestingLimit
|
|
52
77
|
};
|
|
53
78
|
return adapter.handle({
|
|
54
79
|
routes: jobs.routes,
|
|
@@ -89,9 +114,12 @@ const handleNextRequest = async (request, routes, router, options, guards, schem
|
|
|
89
114
|
route: matched.match.route,
|
|
90
115
|
params: matched.match.params
|
|
91
116
|
},
|
|
92
|
-
query:
|
|
117
|
+
query: (0, kizunajs_adapter.entriesToObject)(url.searchParams),
|
|
93
118
|
headers: (0, kizunajs_adapter.headersToObject)(request.headers),
|
|
94
|
-
readBody: (route) => (0, kizunajs_adapter.parseFetchBody)(request, route)
|
|
119
|
+
readBody: (route) => (0, kizunajs_adapter.parseFetchBody)(request, route, (0, kizunajs_adapter.bodyLimitOf)(route, configBodyLimit)),
|
|
120
|
+
readRawBody: (route) => (0, kizunajs_adapter.readBodyText)(request, (0, kizunajs_adapter.bodyLimitOf)(route, configBodyLimit)),
|
|
121
|
+
configBodyLimit,
|
|
122
|
+
configNestingLimit
|
|
95
123
|
};
|
|
96
124
|
return adapter.handle({
|
|
97
125
|
routes,
|
|
@@ -113,9 +141,12 @@ const handleNextRequest = async (request, routes, router, options, guards, schem
|
|
|
113
141
|
kind: "core-match",
|
|
114
142
|
path: url.pathname
|
|
115
143
|
},
|
|
116
|
-
query:
|
|
144
|
+
query: (0, kizunajs_adapter.entriesToObject)(url.searchParams),
|
|
117
145
|
headers: (0, kizunajs_adapter.headersToObject)(request.headers),
|
|
118
|
-
readBody: (route) => (0, kizunajs_adapter.parseFetchBody)(request, route)
|
|
146
|
+
readBody: (route) => (0, kizunajs_adapter.parseFetchBody)(request, route, (0, kizunajs_adapter.bodyLimitOf)(route, configBodyLimit)),
|
|
147
|
+
readRawBody: (route) => (0, kizunajs_adapter.readBodyText)(request, (0, kizunajs_adapter.bodyLimitOf)(route, configBodyLimit)),
|
|
148
|
+
configBodyLimit,
|
|
149
|
+
configNestingLimit
|
|
119
150
|
};
|
|
120
151
|
return adapter.handle({
|
|
121
152
|
routes,
|
|
@@ -145,6 +176,8 @@ function mountNext(api, options) {
|
|
|
145
176
|
const schemes = api[kizunajs_adapter.SCHEMES_META];
|
|
146
177
|
const requestContext = api[kizunajs_adapter.REQUEST_CONTEXT_META];
|
|
147
178
|
const jobsMeta = api[kizunajs_adapter.JOBS_META];
|
|
179
|
+
const configBodyLimit = api[kizunajs_adapter.BODY_LIMIT_META];
|
|
180
|
+
const configNestingLimit = api[kizunajs_adapter.NESTING_LIMIT_META];
|
|
148
181
|
const mountedJobs = jobsMeta ? {
|
|
149
182
|
routes: (0, kizunajs_adapter.jobRoutes)(jobsMeta),
|
|
150
183
|
router: (0, kizunajs_adapter.jobRouter)(jobsMeta),
|
|
@@ -160,12 +193,13 @@ function mountNext(api, options) {
|
|
|
160
193
|
const pluginRoutes = (0, kizunajs_adapter.pluginRoutesOf)(api);
|
|
161
194
|
const pluginRouter = (0, kizunajs_adapter.pluginRouterOf)(api);
|
|
162
195
|
const hasPluginRoutes = Object.keys(pluginRoutes).length > 0;
|
|
163
|
-
const handler = async (
|
|
196
|
+
const handler = async (incoming) => {
|
|
197
|
+
const request = (0, kizunajs_adapter.isMethodOverride)(incoming.method, incoming.headers.get(kizunajs_adapter.METHOD_OVERRIDE_HEADER), incoming.headers.get("content-type")) ? await asGetRequest(incoming) : incoming;
|
|
164
198
|
if (hasPluginRoutes) {
|
|
165
199
|
const pathname = new URL(request.url).pathname;
|
|
166
|
-
if (!((0, kizunajs_adapter.matchRoute)(request.method, pathname, api.routes, options?.basePath).kind === "matched") && (0, kizunajs_adapter.matchRoute)(request.method, pathname, pluginRoutes, options?.basePath).kind === "matched") return handleNextRequest(request, pluginRoutes, pluginRouter, handlerOptions, guards, schemes, requestContext, pluginExports, void 0);
|
|
200
|
+
if (!((0, kizunajs_adapter.matchRoute)(request.method, pathname, api.routes, options?.basePath).kind === "matched") && (0, kizunajs_adapter.matchRoute)(request.method, pathname, pluginRoutes, options?.basePath).kind === "matched") return handleNextRequest(request, pluginRoutes, pluginRouter, handlerOptions, guards, schemes, requestContext, pluginExports, void 0, configBodyLimit, configNestingLimit);
|
|
167
201
|
}
|
|
168
|
-
return handleNextRequest(request, api.routes, api[kizunajs_adapter.ROUTER_META], handlerOptions, guards, schemes, requestContext, pluginExports, mountedJobs);
|
|
202
|
+
return handleNextRequest(request, api.routes, api[kizunajs_adapter.ROUTER_META], handlerOptions, guards, schemes, requestContext, pluginExports, mountedJobs, configBodyLimit, configNestingLimit);
|
|
169
203
|
};
|
|
170
204
|
return {
|
|
171
205
|
GET: handler,
|
|
@@ -194,13 +228,27 @@ function mountNext(api, options) {
|
|
|
194
228
|
* basePath: '/api',
|
|
195
229
|
* });
|
|
196
230
|
*/
|
|
197
|
-
const nextAdapter = (defaults) =>
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
231
|
+
const nextAdapter = (defaults) => {
|
|
232
|
+
const inProcess = /* @__PURE__ */ new WeakMap();
|
|
233
|
+
return {
|
|
234
|
+
name: "next",
|
|
235
|
+
mount: (api, options) => mountNext(api, {
|
|
236
|
+
...defaults,
|
|
237
|
+
...options
|
|
238
|
+
}),
|
|
239
|
+
fetch: (api, request) => {
|
|
240
|
+
let handler = inProcess.get(api);
|
|
241
|
+
if (handler === void 0) {
|
|
242
|
+
handler = mountNext(api, {
|
|
243
|
+
...defaults,
|
|
244
|
+
basePath: void 0
|
|
245
|
+
}).GET;
|
|
246
|
+
inProcess.set(api, handler);
|
|
247
|
+
}
|
|
248
|
+
return handler(new next_server_js.NextRequest(request));
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
};
|
|
204
252
|
//#endregion
|
|
205
253
|
Object.defineProperty(exports, "NextRequest", {
|
|
206
254
|
enumerable: true,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Adapter, ApiWithRouter, ErrorFormatter, GUARDS_META, GuardMap, JOBS_META, JobRunner, Jobs, REQUEST_CONTEXT_META, RequestContextMap, Router, Routes, SCHEMES_META } from "kizunajs/adapter";
|
|
1
|
+
import { Adapter, ApiWithRouter, BODY_LIMIT_META, ErrorFormatter, GUARDS_META, GuardMap, JOBS_META, JobRunner, Jobs, NESTING_LIMIT_META, REQUEST_CONTEXT_META, RequestContextMap, Router, Routes, SCHEMES_META } from "kizunajs/adapter";
|
|
2
2
|
import { SecurityScheme } from "kizunajs";
|
|
3
3
|
import { NextRequest, NextRequest as NextRequest$1, NextResponse, NextResponse as NextResponse$1 } from "next/server.js";
|
|
4
4
|
|
|
@@ -51,7 +51,7 @@ interface NextHandlerOptions {
|
|
|
51
51
|
*/
|
|
52
52
|
responseValidation?: boolean;
|
|
53
53
|
}
|
|
54
|
-
declare const handleNextRequest: <T extends Routes>(request: NextRequest$1, routes: T, router: Router<T, NextHandlerContext>, options?: NextHandlerOptions, guards?: GuardMap<NextHandlerContext>, schemes?: Record<string, SecurityScheme>, requestContext?: RequestContextMap<NextHandlerContext>, pluginExports?: Record<string, unknown>, jobs?: MountedJobs) => Promise<NextResponse$1>;
|
|
54
|
+
declare const handleNextRequest: <T extends Routes>(request: NextRequest$1, routes: T, router: Router<T, NextHandlerContext>, options?: NextHandlerOptions, guards?: GuardMap<NextHandlerContext>, schemes?: Record<string, SecurityScheme>, requestContext?: RequestContextMap<NextHandlerContext>, pluginExports?: Record<string, unknown>, jobs?: MountedJobs, configBodyLimit?: number, configNestingLimit?: number) => Promise<NextResponse$1>;
|
|
55
55
|
type HttpHandlers = {
|
|
56
56
|
GET: HttpHandler;
|
|
57
57
|
HEAD: HttpHandler;
|
|
@@ -67,6 +67,8 @@ type NextApiWithRouter = ApiWithRouter & {
|
|
|
67
67
|
readonly [SCHEMES_META]?: unknown;
|
|
68
68
|
readonly [REQUEST_CONTEXT_META]?: unknown;
|
|
69
69
|
readonly [JOBS_META]?: unknown;
|
|
70
|
+
readonly [BODY_LIMIT_META]?: unknown;
|
|
71
|
+
readonly [NESTING_LIMIT_META]?: unknown;
|
|
70
72
|
};
|
|
71
73
|
type NextApi<R extends Routes = Routes> = ApiWithRouter<R> & {
|
|
72
74
|
readonly [GUARDS_META]?: unknown;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Adapter, ApiWithRouter, ErrorFormatter, GUARDS_META, GuardMap, JOBS_META, JobRunner, Jobs, REQUEST_CONTEXT_META, RequestContextMap, Router, Routes, SCHEMES_META } from "kizunajs/adapter";
|
|
1
|
+
import { Adapter, ApiWithRouter, BODY_LIMIT_META, ErrorFormatter, GUARDS_META, GuardMap, JOBS_META, JobRunner, Jobs, NESTING_LIMIT_META, REQUEST_CONTEXT_META, RequestContextMap, Router, Routes, SCHEMES_META } from "kizunajs/adapter";
|
|
2
2
|
import { NextRequest, NextRequest as NextRequest$1, NextResponse, NextResponse as NextResponse$1 } from "next/server.js";
|
|
3
3
|
import { SecurityScheme } from "kizunajs";
|
|
4
4
|
|
|
@@ -51,7 +51,7 @@ interface NextHandlerOptions {
|
|
|
51
51
|
*/
|
|
52
52
|
responseValidation?: boolean;
|
|
53
53
|
}
|
|
54
|
-
declare const handleNextRequest: <T extends Routes>(request: NextRequest$1, routes: T, router: Router<T, NextHandlerContext>, options?: NextHandlerOptions, guards?: GuardMap<NextHandlerContext>, schemes?: Record<string, SecurityScheme>, requestContext?: RequestContextMap<NextHandlerContext>, pluginExports?: Record<string, unknown>, jobs?: MountedJobs) => Promise<NextResponse$1>;
|
|
54
|
+
declare const handleNextRequest: <T extends Routes>(request: NextRequest$1, routes: T, router: Router<T, NextHandlerContext>, options?: NextHandlerOptions, guards?: GuardMap<NextHandlerContext>, schemes?: Record<string, SecurityScheme>, requestContext?: RequestContextMap<NextHandlerContext>, pluginExports?: Record<string, unknown>, jobs?: MountedJobs, configBodyLimit?: number, configNestingLimit?: number) => Promise<NextResponse$1>;
|
|
55
55
|
type HttpHandlers = {
|
|
56
56
|
GET: HttpHandler;
|
|
57
57
|
HEAD: HttpHandler;
|
|
@@ -67,6 +67,8 @@ type NextApiWithRouter = ApiWithRouter & {
|
|
|
67
67
|
readonly [SCHEMES_META]?: unknown;
|
|
68
68
|
readonly [REQUEST_CONTEXT_META]?: unknown;
|
|
69
69
|
readonly [JOBS_META]?: unknown;
|
|
70
|
+
readonly [BODY_LIMIT_META]?: unknown;
|
|
71
|
+
readonly [NESTING_LIMIT_META]?: unknown;
|
|
70
72
|
};
|
|
71
73
|
type NextApi<R extends Routes = Routes> = ApiWithRouter<R> & {
|
|
72
74
|
readonly [GUARDS_META]?: unknown;
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,36 @@
|
|
|
1
|
-
import { GUARDS_META, JOBS_META, REQUEST_CONTEXT_META, ROUTER_META, SCHEMES_META,
|
|
2
|
-
import { NextRequest, NextResponse, NextResponse as NextResponse$1 } from "next/server.js";
|
|
1
|
+
import { BODY_LIMIT_META, GUARDS_META, JOBS_META, METHOD_OVERRIDE_HEADER, NESTING_LIMIT_META, REQUEST_CONTEXT_META, ROUTER_META, SCHEMES_META, bodyLimitOf, defineAdapter, entriesToObject, headersToObject, isMethodOverride, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseFetchBody, pluginExportsOf, pluginRouterOf, pluginRoutesOf, readBodyText, renderJsonResult } from "kizunajs/adapter";
|
|
2
|
+
import { NextRequest, NextRequest as NextRequest$1, NextResponse, NextResponse as NextResponse$1, after } from "next/server.js";
|
|
3
3
|
//#region src/server.ts
|
|
4
4
|
const jsonResponse = (status, body, headers, raw = false) => new NextResponse$1(body === null || body === void 0 ? null : raw ? body : JSON.stringify(body), {
|
|
5
5
|
status,
|
|
6
6
|
headers
|
|
7
7
|
});
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The GET a method-override POST stands in for: its form body appended to the
|
|
10
|
+
* URL's query, so the GET route reads it as it reads any query.
|
|
11
|
+
*/
|
|
12
|
+
const asGetRequest = async (request) => {
|
|
13
|
+
const url = new URL(request.url);
|
|
14
|
+
for (const [key, value] of new URLSearchParams(await request.text())) url.searchParams.append(key, value);
|
|
15
|
+
const headers = new Headers(request.headers);
|
|
16
|
+
headers.delete("content-type");
|
|
17
|
+
headers.delete("content-length");
|
|
18
|
+
headers.delete(METHOD_OVERRIDE_HEADER);
|
|
19
|
+
return new NextRequest$1(url, {
|
|
20
|
+
method: "GET",
|
|
21
|
+
headers,
|
|
22
|
+
signal: request.signal
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const handleNextRequest = async (request, routes, router, options, guards, schemes, requestContext, pluginExports, jobs, configBodyLimit, configNestingLimit) => {
|
|
9
26
|
const url = new URL(request.url);
|
|
10
|
-
const adapter =
|
|
27
|
+
const adapter = defineAdapter({
|
|
11
28
|
buildHandlerContext: (adapterRequest) => ({ request: adapterRequest.request }),
|
|
29
|
+
waitUntil: (promise) => {
|
|
30
|
+
try {
|
|
31
|
+
after(promise);
|
|
32
|
+
} catch {}
|
|
33
|
+
},
|
|
12
34
|
respond: (result) => {
|
|
13
35
|
if (result.kind === "raw-response") return result.response;
|
|
14
36
|
const rendered = renderJsonResult(result, options?.formatError, request, request.method);
|
|
@@ -45,9 +67,12 @@ const handleNextRequest = async (request, routes, router, options, guards, schem
|
|
|
45
67
|
route: matchedJob.match.route,
|
|
46
68
|
params: matchedJob.match.params
|
|
47
69
|
},
|
|
48
|
-
query:
|
|
70
|
+
query: entriesToObject(url.searchParams),
|
|
49
71
|
headers: headersToObject(request.headers),
|
|
50
|
-
readBody: (route) => parseFetchBody(request, route)
|
|
72
|
+
readBody: (route) => parseFetchBody(request, route, bodyLimitOf(route, configBodyLimit)),
|
|
73
|
+
readRawBody: (route) => readBodyText(request, bodyLimitOf(route, configBodyLimit)),
|
|
74
|
+
configBodyLimit,
|
|
75
|
+
configNestingLimit
|
|
51
76
|
};
|
|
52
77
|
return adapter.handle({
|
|
53
78
|
routes: jobs.routes,
|
|
@@ -88,9 +113,12 @@ const handleNextRequest = async (request, routes, router, options, guards, schem
|
|
|
88
113
|
route: matched.match.route,
|
|
89
114
|
params: matched.match.params
|
|
90
115
|
},
|
|
91
|
-
query:
|
|
116
|
+
query: entriesToObject(url.searchParams),
|
|
92
117
|
headers: headersToObject(request.headers),
|
|
93
|
-
readBody: (route) => parseFetchBody(request, route)
|
|
118
|
+
readBody: (route) => parseFetchBody(request, route, bodyLimitOf(route, configBodyLimit)),
|
|
119
|
+
readRawBody: (route) => readBodyText(request, bodyLimitOf(route, configBodyLimit)),
|
|
120
|
+
configBodyLimit,
|
|
121
|
+
configNestingLimit
|
|
94
122
|
};
|
|
95
123
|
return adapter.handle({
|
|
96
124
|
routes,
|
|
@@ -112,9 +140,12 @@ const handleNextRequest = async (request, routes, router, options, guards, schem
|
|
|
112
140
|
kind: "core-match",
|
|
113
141
|
path: url.pathname
|
|
114
142
|
},
|
|
115
|
-
query:
|
|
143
|
+
query: entriesToObject(url.searchParams),
|
|
116
144
|
headers: headersToObject(request.headers),
|
|
117
|
-
readBody: (route) => parseFetchBody(request, route)
|
|
145
|
+
readBody: (route) => parseFetchBody(request, route, bodyLimitOf(route, configBodyLimit)),
|
|
146
|
+
readRawBody: (route) => readBodyText(request, bodyLimitOf(route, configBodyLimit)),
|
|
147
|
+
configBodyLimit,
|
|
148
|
+
configNestingLimit
|
|
118
149
|
};
|
|
119
150
|
return adapter.handle({
|
|
120
151
|
routes,
|
|
@@ -144,6 +175,8 @@ function mountNext(api, options) {
|
|
|
144
175
|
const schemes = api[SCHEMES_META];
|
|
145
176
|
const requestContext = api[REQUEST_CONTEXT_META];
|
|
146
177
|
const jobsMeta = api[JOBS_META];
|
|
178
|
+
const configBodyLimit = api[BODY_LIMIT_META];
|
|
179
|
+
const configNestingLimit = api[NESTING_LIMIT_META];
|
|
147
180
|
const mountedJobs = jobsMeta ? {
|
|
148
181
|
routes: jobRoutes(jobsMeta),
|
|
149
182
|
router: jobRouter(jobsMeta),
|
|
@@ -159,12 +192,13 @@ function mountNext(api, options) {
|
|
|
159
192
|
const pluginRoutes = pluginRoutesOf(api);
|
|
160
193
|
const pluginRouter = pluginRouterOf(api);
|
|
161
194
|
const hasPluginRoutes = Object.keys(pluginRoutes).length > 0;
|
|
162
|
-
const handler = async (
|
|
195
|
+
const handler = async (incoming) => {
|
|
196
|
+
const request = isMethodOverride(incoming.method, incoming.headers.get(METHOD_OVERRIDE_HEADER), incoming.headers.get("content-type")) ? await asGetRequest(incoming) : incoming;
|
|
163
197
|
if (hasPluginRoutes) {
|
|
164
198
|
const pathname = new URL(request.url).pathname;
|
|
165
|
-
if (!(matchRoute(request.method, pathname, api.routes, options?.basePath).kind === "matched") && matchRoute(request.method, pathname, pluginRoutes, options?.basePath).kind === "matched") return handleNextRequest(request, pluginRoutes, pluginRouter, handlerOptions, guards, schemes, requestContext, pluginExports, void 0);
|
|
199
|
+
if (!(matchRoute(request.method, pathname, api.routes, options?.basePath).kind === "matched") && matchRoute(request.method, pathname, pluginRoutes, options?.basePath).kind === "matched") return handleNextRequest(request, pluginRoutes, pluginRouter, handlerOptions, guards, schemes, requestContext, pluginExports, void 0, configBodyLimit, configNestingLimit);
|
|
166
200
|
}
|
|
167
|
-
return handleNextRequest(request, api.routes, api[ROUTER_META], handlerOptions, guards, schemes, requestContext, pluginExports, mountedJobs);
|
|
201
|
+
return handleNextRequest(request, api.routes, api[ROUTER_META], handlerOptions, guards, schemes, requestContext, pluginExports, mountedJobs, configBodyLimit, configNestingLimit);
|
|
168
202
|
};
|
|
169
203
|
return {
|
|
170
204
|
GET: handler,
|
|
@@ -193,12 +227,26 @@ function mountNext(api, options) {
|
|
|
193
227
|
* basePath: '/api',
|
|
194
228
|
* });
|
|
195
229
|
*/
|
|
196
|
-
const nextAdapter = (defaults) =>
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
230
|
+
const nextAdapter = (defaults) => {
|
|
231
|
+
const inProcess = /* @__PURE__ */ new WeakMap();
|
|
232
|
+
return {
|
|
233
|
+
name: "next",
|
|
234
|
+
mount: (api, options) => mountNext(api, {
|
|
235
|
+
...defaults,
|
|
236
|
+
...options
|
|
237
|
+
}),
|
|
238
|
+
fetch: (api, request) => {
|
|
239
|
+
let handler = inProcess.get(api);
|
|
240
|
+
if (handler === void 0) {
|
|
241
|
+
handler = mountNext(api, {
|
|
242
|
+
...defaults,
|
|
243
|
+
basePath: void 0
|
|
244
|
+
}).GET;
|
|
245
|
+
inProcess.set(api, handler);
|
|
246
|
+
}
|
|
247
|
+
return handler(new NextRequest$1(request));
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
};
|
|
203
251
|
//#endregion
|
|
204
252
|
export { NextRequest, NextResponse, handleNextRequest, mountNext, nextAdapter };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kizunajs/next",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.40",
|
|
4
4
|
"description": "Next.js App Router adapter for Kizuna.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kizunajs",
|
|
@@ -56,16 +56,16 @@
|
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
+
"kizunajs": "2.0.0-beta.40",
|
|
59
60
|
"next": ">=16.0.0",
|
|
60
|
-
"zod": "^4.0.0"
|
|
61
|
-
"kizunajs": "2.0.0-beta.4"
|
|
61
|
+
"zod": "^4.0.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"
|
|
65
|
-
"
|
|
64
|
+
"kizunajs": "2.0.0-beta.40",
|
|
65
|
+
"next": "^16.4.5",
|
|
66
|
+
"tsdown": "^0.21.10",
|
|
66
67
|
"typescript": "^6.0.3",
|
|
67
|
-
"zod": "^4.
|
|
68
|
-
"kizunajs": "2.0.0-beta.4"
|
|
68
|
+
"zod": "^4.6.7"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "tsdown src/index.ts --format esm,cjs --dts --clean --external kizunajs --external zod",
|