@taserjs/router 0.1.13 → 0.2.1
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/README.md +5 -5
- package/dist/builder-DYfjARJF.js +226 -0
- package/dist/builder-DYfjARJF.js.map +1 -0
- package/dist/builder-EWuIQcdU.cjs +283 -0
- package/dist/hono-Ddk3waH-.cjs +42 -0
- package/dist/hono-kDZSomjd.js +39 -0
- package/dist/hono-kDZSomjd.js.map +1 -0
- package/dist/index.cjs +60 -0
- package/dist/index.d.cts +104 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +104 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/body-limit.cjs +15 -0
- package/dist/middleware/body-limit.d.cts +11 -0
- package/dist/middleware/body-limit.d.cts.map +1 -0
- package/dist/middleware/body-limit.d.ts +11 -0
- package/dist/middleware/body-limit.d.ts.map +1 -0
- package/dist/middleware/body-limit.js +16 -0
- package/dist/middleware/body-limit.js.map +1 -0
- package/dist/middleware/compress.cjs +10 -0
- package/dist/middleware/compress.d.cts +8 -0
- package/dist/middleware/compress.d.cts.map +1 -0
- package/dist/middleware/compress.d.ts +8 -0
- package/dist/middleware/compress.d.ts.map +1 -0
- package/dist/middleware/compress.js +10 -0
- package/dist/middleware/compress.js.map +1 -0
- package/dist/middleware/cookie.cjs +87 -0
- package/dist/middleware/cookie.d.cts +26 -0
- package/dist/middleware/cookie.d.cts.map +1 -0
- package/dist/middleware/cookie.d.ts +26 -0
- package/dist/middleware/cookie.d.ts.map +1 -0
- package/dist/middleware/cookie.js +87 -0
- package/dist/middleware/cookie.js.map +1 -0
- package/dist/middleware/cors.cjs +9 -0
- package/dist/middleware/cors.d.cts +7 -0
- package/dist/middleware/cors.d.cts.map +1 -0
- package/dist/middleware/cors.d.ts +7 -0
- package/dist/middleware/cors.d.ts.map +1 -0
- package/dist/middleware/cors.js +10 -0
- package/dist/middleware/cors.js.map +1 -0
- package/dist/middleware/csrf.cjs +9 -0
- package/dist/middleware/csrf.d.cts +7 -0
- package/dist/middleware/csrf.d.cts.map +1 -0
- package/dist/middleware/csrf.d.ts +7 -0
- package/dist/middleware/csrf.d.ts.map +1 -0
- package/dist/middleware/csrf.js +10 -0
- package/dist/middleware/csrf.js.map +1 -0
- package/dist/middleware/etag.cjs +10 -0
- package/dist/middleware/etag.d.cts +8 -0
- package/dist/middleware/etag.d.cts.map +1 -0
- package/dist/middleware/etag.d.ts +8 -0
- package/dist/middleware/etag.d.ts.map +1 -0
- package/dist/middleware/etag.js +10 -0
- package/dist/middleware/etag.js.map +1 -0
- package/dist/middleware/index.cjs +39 -0
- package/dist/middleware/index.d.cts +11 -0
- package/dist/middleware/index.d.ts +11 -0
- package/dist/middleware/index.js +11 -0
- package/dist/middleware/jwk.cjs +12 -0
- package/dist/middleware/jwk.d.cts +9 -0
- package/dist/middleware/jwk.d.cts.map +1 -0
- package/dist/middleware/jwk.d.ts +9 -0
- package/dist/middleware/jwk.d.ts.map +1 -0
- package/dist/middleware/jwk.js +13 -0
- package/dist/middleware/jwk.js.map +1 -0
- package/dist/middleware/jwt.cjs +21 -0
- package/dist/middleware/jwt.d.cts +13 -0
- package/dist/middleware/jwt.d.cts.map +1 -0
- package/dist/middleware/jwt.d.ts +13 -0
- package/dist/middleware/jwt.d.ts.map +1 -0
- package/dist/middleware/jwt.js +17 -0
- package/dist/middleware/jwt.js.map +1 -0
- package/dist/middleware/secure-headers.cjs +10 -0
- package/dist/middleware/secure-headers.d.cts +8 -0
- package/dist/middleware/secure-headers.d.cts.map +1 -0
- package/dist/middleware/secure-headers.d.ts +8 -0
- package/dist/middleware/secure-headers.d.ts.map +1 -0
- package/dist/middleware/secure-headers.js +10 -0
- package/dist/middleware/secure-headers.js.map +1 -0
- package/dist/middleware/timing.cjs +13 -0
- package/dist/middleware/timing.d.cts +8 -0
- package/dist/middleware/timing.d.cts.map +1 -0
- package/dist/middleware/timing.d.ts +8 -0
- package/dist/middleware/timing.d.ts.map +1 -0
- package/dist/middleware/timing.js +10 -0
- package/dist/middleware/timing.js.map +1 -0
- package/dist/reply.cjs +128 -0
- package/dist/reply.d.cts +2 -0
- package/dist/reply.d.ts +2 -0
- package/dist/reply.js +2 -0
- package/dist/stream.cjs +32 -0
- package/dist/stream.d.cts +2 -0
- package/dist/stream.d.ts +2 -0
- package/dist/stream.js +2 -0
- package/dist/types-87QgPePQ.d.cts +294 -0
- package/dist/types-87QgPePQ.d.cts.map +1 -0
- package/dist/types-oo9In1Ss.d.ts +294 -0
- package/dist/types-oo9In1Ss.d.ts.map +1 -0
- package/package.json +49 -107
- package/src/builder.ts +753 -0
- package/src/context.ts +11 -0
- package/src/hono.ts +75 -0
- package/src/index.ts +67 -49
- package/src/middleware/body-limit.ts +17 -5
- package/src/middleware/compress.ts +7 -6
- package/src/middleware/cookie.ts +128 -0
- package/src/middleware/cors.ts +5 -6
- package/src/middleware/csrf.ts +5 -6
- package/src/middleware/etag.ts +7 -6
- package/src/middleware/index.ts +35 -0
- package/src/middleware/jwk.ts +12 -46
- package/src/middleware/jwt.ts +21 -26
- package/src/middleware/secure-headers.ts +7 -6
- package/src/middleware/timing.ts +9 -6
- package/src/reply.ts +26 -1
- package/src/stream.ts +10 -1
- package/src/taser.ts +55 -0
- package/src/types.ts +802 -0
- package/dist/cjs/builder/app.cjs +0 -27
- package/dist/cjs/builder/app.cjs.map +0 -1
- package/dist/cjs/builder/app.d.cts +0 -11
- package/dist/cjs/builder/constants.cjs +0 -11
- package/dist/cjs/builder/constants.cjs.map +0 -1
- package/dist/cjs/builder/constants.d.cts +0 -3
- package/dist/cjs/builder/middleware-unit.cjs +0 -64
- package/dist/cjs/builder/middleware-unit.cjs.map +0 -1
- package/dist/cjs/builder/middleware-unit.d.cts +0 -34
- package/dist/cjs/builder/middleware.cjs +0 -20
- package/dist/cjs/builder/middleware.cjs.map +0 -1
- package/dist/cjs/builder/middleware.d.cts +0 -2
- package/dist/cjs/builder/normalize.cjs +0 -10
- package/dist/cjs/builder/normalize.cjs.map +0 -1
- package/dist/cjs/builder/normalize.d.cts +0 -2
- package/dist/cjs/builder/route.cjs +0 -83
- package/dist/cjs/builder/route.cjs.map +0 -1
- package/dist/cjs/builder/route.d.cts +0 -4
- package/dist/cjs/builder/router.cjs +0 -88
- package/dist/cjs/builder/router.cjs.map +0 -1
- package/dist/cjs/builder/router.d.cts +0 -26
- package/dist/cjs/builder/standalone.cjs +0 -30
- package/dist/cjs/builder/standalone.cjs.map +0 -1
- package/dist/cjs/builder/standalone.d.cts +0 -23
- package/dist/cjs/context/create-context.cjs +0 -8
- package/dist/cjs/context/create-context.cjs.map +0 -1
- package/dist/cjs/context/create-context.d.cts +0 -5
- package/dist/cjs/define/middleware.cjs +0 -22
- package/dist/cjs/define/middleware.cjs.map +0 -1
- package/dist/cjs/define/middleware.d.cts +0 -45
- package/dist/cjs/define/validators.cjs +0 -14
- package/dist/cjs/define/validators.cjs.map +0 -1
- package/dist/cjs/define/validators.d.cts +0 -8
- package/dist/cjs/index.cjs +0 -26
- package/dist/cjs/index.d.cts +0 -17
- package/dist/cjs/middleware/body-limit.cjs +0 -12
- package/dist/cjs/middleware/body-limit.cjs.map +0 -1
- package/dist/cjs/middleware/body-limit.d.cts +0 -3
- package/dist/cjs/middleware/compress.cjs +0 -12
- package/dist/cjs/middleware/compress.cjs.map +0 -1
- package/dist/cjs/middleware/compress.d.cts +0 -3
- package/dist/cjs/middleware/cors.cjs +0 -12
- package/dist/cjs/middleware/cors.cjs.map +0 -1
- package/dist/cjs/middleware/cors.d.cts +0 -3
- package/dist/cjs/middleware/csrf.cjs +0 -12
- package/dist/cjs/middleware/csrf.cjs.map +0 -1
- package/dist/cjs/middleware/csrf.d.cts +0 -3
- package/dist/cjs/middleware/etag.cjs +0 -12
- package/dist/cjs/middleware/etag.cjs.map +0 -1
- package/dist/cjs/middleware/etag.d.cts +0 -3
- package/dist/cjs/middleware/hono-mw.cjs +0 -23
- package/dist/cjs/middleware/hono-mw.cjs.map +0 -1
- package/dist/cjs/middleware/hono-mw.d.cts +0 -17
- package/dist/cjs/middleware/jwk.cjs +0 -30
- package/dist/cjs/middleware/jwk.cjs.map +0 -1
- package/dist/cjs/middleware/jwk.d.cts +0 -14
- package/dist/cjs/middleware/jwt.cjs +0 -20
- package/dist/cjs/middleware/jwt.cjs.map +0 -1
- package/dist/cjs/middleware/jwt.d.cts +0 -12
- package/dist/cjs/middleware/secure-headers.cjs +0 -12
- package/dist/cjs/middleware/secure-headers.cjs.map +0 -1
- package/dist/cjs/middleware/secure-headers.d.cts +0 -3
- package/dist/cjs/middleware/timing.cjs +0 -12
- package/dist/cjs/middleware/timing.cjs.map +0 -1
- package/dist/cjs/middleware/timing.d.cts +0 -3
- package/dist/cjs/reply.cjs +0 -9
- package/dist/cjs/reply.d.cts +0 -1
- package/dist/cjs/stream.cjs +0 -9
- package/dist/cjs/stream.d.cts +0 -1
- package/dist/cjs/types/app.d.cts +0 -29
- package/dist/cjs/types/index.d.cts +0 -297
- package/dist/cjs/types/returns.d.cts +0 -34
- package/dist/cjs/types/schema.d.cts +0 -14
- package/dist/cjs/types/type-utils.d.cts +0 -50
- package/dist/cjs/types/units.d.cts +0 -71
- package/dist/esm/builder/app.d.ts +0 -11
- package/dist/esm/builder/app.js +0 -26
- package/dist/esm/builder/app.js.map +0 -1
- package/dist/esm/builder/constants.d.ts +0 -3
- package/dist/esm/builder/constants.js +0 -11
- package/dist/esm/builder/constants.js.map +0 -1
- package/dist/esm/builder/middleware-unit.d.ts +0 -34
- package/dist/esm/builder/middleware-unit.js +0 -64
- package/dist/esm/builder/middleware-unit.js.map +0 -1
- package/dist/esm/builder/middleware.d.ts +0 -2
- package/dist/esm/builder/middleware.js +0 -20
- package/dist/esm/builder/middleware.js.map +0 -1
- package/dist/esm/builder/normalize.d.ts +0 -2
- package/dist/esm/builder/normalize.js +0 -10
- package/dist/esm/builder/normalize.js.map +0 -1
- package/dist/esm/builder/route.d.ts +0 -4
- package/dist/esm/builder/route.js +0 -83
- package/dist/esm/builder/route.js.map +0 -1
- package/dist/esm/builder/router.d.ts +0 -26
- package/dist/esm/builder/router.js +0 -87
- package/dist/esm/builder/router.js.map +0 -1
- package/dist/esm/builder/standalone.d.ts +0 -23
- package/dist/esm/builder/standalone.js +0 -29
- package/dist/esm/builder/standalone.js.map +0 -1
- package/dist/esm/context/create-context.d.ts +0 -5
- package/dist/esm/context/create-context.js +0 -8
- package/dist/esm/context/create-context.js.map +0 -1
- package/dist/esm/define/middleware.d.ts +0 -45
- package/dist/esm/define/middleware.js +0 -22
- package/dist/esm/define/middleware.js.map +0 -1
- package/dist/esm/define/validators.d.ts +0 -8
- package/dist/esm/define/validators.js +0 -14
- package/dist/esm/define/validators.js.map +0 -1
- package/dist/esm/index.d.ts +0 -17
- package/dist/esm/index.js +0 -7
- package/dist/esm/middleware/body-limit.d.ts +0 -3
- package/dist/esm/middleware/body-limit.js +0 -11
- package/dist/esm/middleware/body-limit.js.map +0 -1
- package/dist/esm/middleware/compress.d.ts +0 -3
- package/dist/esm/middleware/compress.js +0 -11
- package/dist/esm/middleware/compress.js.map +0 -1
- package/dist/esm/middleware/cors.d.ts +0 -3
- package/dist/esm/middleware/cors.js +0 -11
- package/dist/esm/middleware/cors.js.map +0 -1
- package/dist/esm/middleware/csrf.d.ts +0 -3
- package/dist/esm/middleware/csrf.js +0 -11
- package/dist/esm/middleware/csrf.js.map +0 -1
- package/dist/esm/middleware/etag.d.ts +0 -3
- package/dist/esm/middleware/etag.js +0 -11
- package/dist/esm/middleware/etag.js.map +0 -1
- package/dist/esm/middleware/hono-mw.d.ts +0 -17
- package/dist/esm/middleware/hono-mw.js +0 -23
- package/dist/esm/middleware/hono-mw.js.map +0 -1
- package/dist/esm/middleware/jwk.d.ts +0 -14
- package/dist/esm/middleware/jwk.js +0 -29
- package/dist/esm/middleware/jwk.js.map +0 -1
- package/dist/esm/middleware/jwt.d.ts +0 -12
- package/dist/esm/middleware/jwt.js +0 -19
- package/dist/esm/middleware/jwt.js.map +0 -1
- package/dist/esm/middleware/secure-headers.d.ts +0 -3
- package/dist/esm/middleware/secure-headers.js +0 -11
- package/dist/esm/middleware/secure-headers.js.map +0 -1
- package/dist/esm/middleware/timing.d.ts +0 -3
- package/dist/esm/middleware/timing.js +0 -11
- package/dist/esm/middleware/timing.js.map +0 -1
- package/dist/esm/reply.d.ts +0 -1
- package/dist/esm/reply.js +0 -1
- package/dist/esm/stream.d.ts +0 -1
- package/dist/esm/stream.js +0 -1
- package/dist/esm/types/app.d.ts +0 -29
- package/dist/esm/types/index.d.ts +0 -297
- package/dist/esm/types/returns.d.ts +0 -34
- package/dist/esm/types/schema.d.ts +0 -14
- package/dist/esm/types/type-utils.d.ts +0 -50
- package/dist/esm/types/units.d.ts +0 -71
- package/src/builder/app.ts +0 -39
- package/src/builder/constants.ts +0 -4
- package/src/builder/middleware-unit.ts +0 -71
- package/src/builder/middleware.ts +0 -23
- package/src/builder/normalize.ts +0 -13
- package/src/builder/route.ts +0 -137
- package/src/builder/router.ts +0 -144
- package/src/builder/standalone.ts +0 -79
- package/src/context/create-context.ts +0 -19
- package/src/define/middleware.ts +0 -214
- package/src/define/validators.ts +0 -22
- package/src/middleware/hono-mw.ts +0 -27
- package/src/types/app.ts +0 -48
- package/src/types/index.ts +0 -801
- package/src/types/returns.ts +0 -61
- package/src/types/schema.ts +0 -21
- package/src/types/type-utils.ts +0 -90
- package/src/types/units.ts +0 -314
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { middleware } from "../define/middleware.js";
|
|
2
|
-
import { honoMw } from "./hono-mw.js";
|
|
3
|
-
import { compress as compress$1 } from "hono/compress";
|
|
4
|
-
//#region src/middleware/compress.ts
|
|
5
|
-
function compress(...args) {
|
|
6
|
-
return middleware(honoMw(compress$1(...args)));
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { compress };
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=compress.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compress.js","names":[],"sources":["../../../src/middleware/compress.ts"],"sourcesContent":["import { compress as honoCompress } from \"hono/compress\";\n\nimport { middleware } from \"../define/middleware.js\";\nimport { honoMw } from \"./hono-mw.js\";\n\nexport function compress(...args: Parameters<typeof honoCompress>) {\n return middleware(honoMw(honoCompress(...args)));\n}\n\nexport type CompressOptions = NonNullable<Parameters<typeof honoCompress>[0]>;\n"],"mappings":";;;;AAKA,SAAgB,SAAS,GAAG,MAAuC;CACjE,OAAO,WAAW,OAAO,WAAa,GAAG,IAAI,CAAC,CAAC;AACjD"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { cors as honoCors } from 'hono/cors';
|
|
2
|
-
export declare function cors(...args: Parameters<typeof honoCors>): import('../types/units.js').DefineMiddlewareResult<unknown, unknown, unknown, {}, Promise<Response>, unknown, unknown, unknown, {}, null, {}>;
|
|
3
|
-
export type CorsOptions = NonNullable<Parameters<typeof honoCors>[0]>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { middleware } from "../define/middleware.js";
|
|
2
|
-
import { honoMw } from "./hono-mw.js";
|
|
3
|
-
import { cors as cors$1 } from "hono/cors";
|
|
4
|
-
//#region src/middleware/cors.ts
|
|
5
|
-
function cors(...args) {
|
|
6
|
-
return middleware(honoMw(cors$1(...args)));
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { cors };
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=cors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cors.js","names":[],"sources":["../../../src/middleware/cors.ts"],"sourcesContent":["import { cors as honoCors } from \"hono/cors\";\n\nimport { middleware } from \"../define/middleware.js\";\nimport { honoMw } from \"./hono-mw.js\";\n\nexport function cors(...args: Parameters<typeof honoCors>) {\n return middleware(honoMw(honoCors(...args)));\n}\n\nexport type CorsOptions = NonNullable<Parameters<typeof honoCors>[0]>;\n"],"mappings":";;;;AAKA,SAAgB,KAAK,GAAG,MAAmC;CACzD,OAAO,WAAW,OAAO,OAAS,GAAG,IAAI,CAAC,CAAC;AAC7C"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { csrf as honoCsrf } from 'hono/csrf';
|
|
2
|
-
export declare function csrf(...args: Parameters<typeof honoCsrf>): import('../types/units.js').DefineMiddlewareResult<unknown, unknown, unknown, {}, Promise<Response>, unknown, unknown, unknown, {}, null, {}>;
|
|
3
|
-
export type CsrfOptions = NonNullable<Parameters<typeof honoCsrf>[0]>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { middleware } from "../define/middleware.js";
|
|
2
|
-
import { honoMw } from "./hono-mw.js";
|
|
3
|
-
import { csrf as csrf$1 } from "hono/csrf";
|
|
4
|
-
//#region src/middleware/csrf.ts
|
|
5
|
-
function csrf(...args) {
|
|
6
|
-
return middleware(honoMw(csrf$1(...args)));
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { csrf };
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=csrf.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"csrf.js","names":[],"sources":["../../../src/middleware/csrf.ts"],"sourcesContent":["import { csrf as honoCsrf } from \"hono/csrf\";\n\nimport { middleware } from \"../define/middleware.js\";\nimport { honoMw } from \"./hono-mw.js\";\n\nexport function csrf(...args: Parameters<typeof honoCsrf>) {\n return middleware(honoMw(honoCsrf(...args)));\n}\n\nexport type CsrfOptions = NonNullable<Parameters<typeof honoCsrf>[0]>;\n"],"mappings":";;;;AAKA,SAAgB,KAAK,GAAG,MAAmC;CACzD,OAAO,WAAW,OAAO,OAAS,GAAG,IAAI,CAAC,CAAC;AAC7C"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { etag as honoEtag } from 'hono/etag';
|
|
2
|
-
export declare function etag(...args: Parameters<typeof honoEtag>): import('../types/units.js').DefineMiddlewareResult<unknown, unknown, unknown, {}, Promise<Response>, unknown, unknown, unknown, {}, null, {}>;
|
|
3
|
-
export type EtagOptions = NonNullable<Parameters<typeof honoEtag>[0]>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { middleware } from "../define/middleware.js";
|
|
2
|
-
import { honoMw } from "./hono-mw.js";
|
|
3
|
-
import { etag as etag$1 } from "hono/etag";
|
|
4
|
-
//#region src/middleware/etag.ts
|
|
5
|
-
function etag(...args) {
|
|
6
|
-
return middleware(honoMw(etag$1(...args)));
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { etag };
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=etag.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"etag.js","names":[],"sources":["../../../src/middleware/etag.ts"],"sourcesContent":["import { etag as honoEtag } from \"hono/etag\";\n\nimport { middleware } from \"../define/middleware.js\";\nimport { honoMw } from \"./hono-mw.js\";\n\nexport function etag(...args: Parameters<typeof honoEtag>) {\n return middleware(honoMw(honoEtag(...args)));\n}\n\nexport type EtagOptions = NonNullable<Parameters<typeof honoEtag>[0]>;\n"],"mappings":";;;;AAKA,SAAgB,KAAK,GAAG,MAAmC;CACzD,OAAO,WAAW,OAAO,OAAS,GAAG,IAAI,CAAC,CAAC;AAC7C"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { MiddlewareHandler } from 'hono';
|
|
2
|
-
import { NextFn } from '../types/units.js';
|
|
3
|
-
/**
|
|
4
|
-
* Adapts a standard Web / Hono-compatible middleware function `(c, next) => ...`
|
|
5
|
-
* into a Taser.js-compatible middleware handler function `(ctx, next) => Promise<Response>`.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import { honoMw } from "@taserjs/router";
|
|
10
|
-
* import { cors } from "hono/cors";
|
|
11
|
-
*
|
|
12
|
-
* const app = t.get("/hello").use(honoMw(cors()));
|
|
13
|
-
* // or
|
|
14
|
-
* const customCors = middleware(honoMw(cors()));
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare function honoMw<TState extends Record<string, unknown> = {}>(middleware: MiddlewareHandler): (ctx: unknown, next: NextFn<TState>) => Promise<Response>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createTaserCompatHandler } from "@taserjs/router-core";
|
|
2
|
-
//#region src/middleware/hono-mw.ts
|
|
3
|
-
/**
|
|
4
|
-
* Adapts a standard Web / Hono-compatible middleware function `(c, next) => ...`
|
|
5
|
-
* into a Taser.js-compatible middleware handler function `(ctx, next) => Promise<Response>`.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import { honoMw } from "@taserjs/router";
|
|
10
|
-
* import { cors } from "hono/cors";
|
|
11
|
-
*
|
|
12
|
-
* const app = t.get("/hello").use(honoMw(cors()));
|
|
13
|
-
* // or
|
|
14
|
-
* const customCors = middleware(honoMw(cors()));
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
function honoMw(middleware) {
|
|
18
|
-
return createTaserCompatHandler(middleware);
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { honoMw };
|
|
22
|
-
|
|
23
|
-
//# sourceMappingURL=hono-mw.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hono-mw.js","names":[],"sources":["../../../src/middleware/hono-mw.ts"],"sourcesContent":["import { createTaserCompatHandler } from \"@taserjs/router-core\";\nimport type { MiddlewareHandler } from \"hono\";\n\nimport type { NextFn } from \"../types/units.js\";\n\n/**\n * Adapts a standard Web / Hono-compatible middleware function `(c, next) => ...`\n * into a Taser.js-compatible middleware handler function `(ctx, next) => Promise<Response>`.\n *\n * @example\n * ```ts\n * import { honoMw } from \"@taserjs/router\";\n * import { cors } from \"hono/cors\";\n *\n * const app = t.get(\"/hello\").use(honoMw(cors()));\n * // or\n * const customCors = middleware(honoMw(cors()));\n * ```\n */\nexport function honoMw<TState extends Record<string, unknown> = {}>(\n middleware: MiddlewareHandler,\n): (ctx: unknown, next: NextFn<TState>) => Promise<Response> {\n return createTaserCompatHandler(middleware) as (\n ctx: unknown,\n next: NextFn<TState>,\n ) => Promise<Response>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,SAAgB,OACd,YAC2D;CAC3D,OAAO,yBAAyB,UAAU;AAI5C"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jwk as honoJwk } from 'hono/jwk';
|
|
2
|
-
import { JwtMiddlewareUnit } from './jwt.js';
|
|
3
|
-
export type JwkOptions = Parameters<typeof honoJwk>[0];
|
|
4
|
-
export type JwkRequestInit = Pick<RequestInit, "headers">;
|
|
5
|
-
export type JwkMiddlewareOptions = JwkOptions & {
|
|
6
|
-
/** Allow `http://` JWKS URLs (local dev). Default false — requires `https://`. */
|
|
7
|
-
allowInsecure?: boolean;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* JWK auth middleware. Invalid or missing tokens return **401** (Hono).
|
|
11
|
-
* Successfully decoded payload is placed in `ctx.state.jwtPayload`.
|
|
12
|
-
* Static `jwks_uri` must use HTTPS unless `allowInsecure: true`.
|
|
13
|
-
*/
|
|
14
|
-
export declare function jwk<TPayload = Record<string, unknown>>(options: JwkMiddlewareOptions, init?: JwkRequestInit): JwtMiddlewareUnit<TPayload>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { middleware } from "../define/middleware.js";
|
|
2
|
-
import { honoMw } from "./hono-mw.js";
|
|
3
|
-
import { jwk as jwk$1 } from "hono/jwk";
|
|
4
|
-
//#region src/middleware/jwk.ts
|
|
5
|
-
function assertJwksScheme(jwksUri, allowInsecure) {
|
|
6
|
-
const scheme = new URL(jwksUri).protocol.replace(":", "");
|
|
7
|
-
if (scheme === "https") return;
|
|
8
|
-
if (scheme === "http" && allowInsecure) return;
|
|
9
|
-
throw new Error(`JWKS URL must use https:// (or http:// with allowInsecure: true): "${jwksUri}"`);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* JWK auth middleware. Invalid or missing tokens return **401** (Hono).
|
|
13
|
-
* Successfully decoded payload is placed in `ctx.state.jwtPayload`.
|
|
14
|
-
* Static `jwks_uri` must use HTTPS unless `allowInsecure: true`.
|
|
15
|
-
*/
|
|
16
|
-
function jwk(options, init) {
|
|
17
|
-
const jwksUri = options.jwks_uri;
|
|
18
|
-
if (typeof jwksUri === "string") assertJwksScheme(jwksUri, options.allowInsecure ?? false);
|
|
19
|
-
const { allowInsecure: _allowInsecure, ...honoOptions } = options;
|
|
20
|
-
const mw = honoMw(jwk$1(honoOptions, init?.headers !== void 0 ? { headers: init.headers } : void 0));
|
|
21
|
-
return middleware((ctx, next) => mw(ctx, async () => {
|
|
22
|
-
const payload = ctx.var.jwtPayload;
|
|
23
|
-
return next({ jwtPayload: payload });
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { jwk };
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=jwk.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwk.js","names":[],"sources":["../../../src/middleware/jwk.ts"],"sourcesContent":["import { jwk as honoJwk } from \"hono/jwk\";\n\nimport { middleware } from \"../define/middleware.js\";\nimport { honoMw } from \"./hono-mw.js\";\nimport type { JwtMiddlewareUnit, JwtPayloadState } from \"./jwt.js\";\n\nexport type JwkOptions = Parameters<typeof honoJwk>[0];\n\nexport type JwkRequestInit = Pick<RequestInit, \"headers\">;\n\nexport type JwkMiddlewareOptions = JwkOptions & {\n /** Allow `http://` JWKS URLs (local dev). Default false — requires `https://`. */\n allowInsecure?: boolean;\n};\n\nfunction assertJwksScheme(jwksUri: string, allowInsecure: boolean): void {\n const scheme = new URL(jwksUri).protocol.replace(\":\", \"\");\n if (scheme === \"https\") {\n return;\n }\n if (scheme === \"http\" && allowInsecure) {\n return;\n }\n throw new Error(`JWKS URL must use https:// (or http:// with allowInsecure: true): \"${jwksUri}\"`);\n}\n\n/**\n * JWK auth middleware. Invalid or missing tokens return **401** (Hono).\n * Successfully decoded payload is placed in `ctx.state.jwtPayload`.\n * Static `jwks_uri` must use HTTPS unless `allowInsecure: true`.\n */\nexport function jwk<TPayload = Record<string, unknown>>(\n options: JwkMiddlewareOptions,\n init?: JwkRequestInit,\n): JwtMiddlewareUnit<TPayload> {\n const jwksUri = options.jwks_uri;\n if (typeof jwksUri === \"string\") {\n assertJwksScheme(jwksUri, options.allowInsecure ?? false);\n }\n\n const { allowInsecure: _allowInsecure, ...honoOptions } = options;\n const safeInit = init?.headers !== undefined ? { headers: init.headers } : undefined;\n const mw = honoMw(honoJwk(honoOptions, safeInit));\n\n return middleware<JwtPayloadState<TPayload>>((ctx, next) =>\n mw(ctx, async () => {\n const payload = (ctx as unknown as { var: { jwtPayload?: unknown } }).var.jwtPayload;\n return next({ jwtPayload: payload as TPayload });\n }),\n );\n}\n"],"mappings":";;;;AAeA,SAAS,iBAAiB,SAAiB,eAA8B;CACvE,MAAM,SAAS,IAAI,IAAI,OAAO,CAAC,CAAC,SAAS,QAAQ,KAAK,EAAE;CACxD,IAAI,WAAW,SACb;CAEF,IAAI,WAAW,UAAU,eACvB;CAEF,MAAM,IAAI,MAAM,sEAAsE,QAAQ,EAAE;AAClG;;;;;;AAOA,SAAgB,IACd,SACA,MAC6B;CAC7B,MAAM,UAAU,QAAQ;CACxB,IAAI,OAAO,YAAY,UACrB,iBAAiB,SAAS,QAAQ,iBAAiB,KAAK;CAG1D,MAAM,EAAE,eAAe,gBAAgB,GAAG,gBAAgB;CAE1D,MAAM,KAAK,OAAO,MAAQ,aADT,MAAM,YAAY,KAAA,IAAY,EAAE,SAAS,KAAK,QAAQ,IAAI,KAAA,CAC5B,CAAC;CAEhD,OAAO,YAAuC,KAAK,SACjD,GAAG,KAAK,YAAY;EAClB,MAAM,UAAW,IAAqD,IAAI;EAC1E,OAAO,KAAK,EAAE,YAAY,QAAoB,CAAC;CACjD,CAAC,CACH;AACF"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jwt as honoJwt } from 'hono/jwt';
|
|
2
|
-
import { MiddlewareReturnFromParts, MiddlewareUnit } from '../types/units.js';
|
|
3
|
-
export type JwtPayloadState<TPayload> = {
|
|
4
|
-
jwtPayload: TPayload;
|
|
5
|
-
};
|
|
6
|
-
export type JwtMiddlewareUnit<TPayload> = MiddlewareUnit<MiddlewareReturnFromParts<unknown, unknown, unknown, JwtPayloadState<TPayload>>>;
|
|
7
|
-
export type JwtOptions = Parameters<typeof honoJwt>[0];
|
|
8
|
-
/**
|
|
9
|
-
* JWT auth middleware. Invalid or missing tokens return **401** (Hono).
|
|
10
|
-
* Successfully decoded payload is placed in `ctx.state.jwtPayload`.
|
|
11
|
-
*/
|
|
12
|
-
export declare function jwt<TPayload = Record<string, unknown>>(options: JwtOptions): JwtMiddlewareUnit<TPayload>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { middleware } from "../define/middleware.js";
|
|
2
|
-
import { honoMw } from "./hono-mw.js";
|
|
3
|
-
import { jwt as jwt$1 } from "hono/jwt";
|
|
4
|
-
//#region src/middleware/jwt.ts
|
|
5
|
-
/**
|
|
6
|
-
* JWT auth middleware. Invalid or missing tokens return **401** (Hono).
|
|
7
|
-
* Successfully decoded payload is placed in `ctx.state.jwtPayload`.
|
|
8
|
-
*/
|
|
9
|
-
function jwt(options) {
|
|
10
|
-
const mw = honoMw(jwt$1(options));
|
|
11
|
-
return middleware((ctx, next) => mw(ctx, async () => {
|
|
12
|
-
const payload = ctx.var.jwtPayload;
|
|
13
|
-
return next({ jwtPayload: payload });
|
|
14
|
-
}));
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
17
|
-
export { jwt };
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=jwt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.js","names":[],"sources":["../../../src/middleware/jwt.ts"],"sourcesContent":["import { jwt as honoJwt } from \"hono/jwt\";\n\nimport { middleware } from \"../define/middleware.js\";\nimport type { MiddlewareReturnFromParts, MiddlewareUnit } from \"../types/units.js\";\nimport { honoMw } from \"./hono-mw.js\";\n\nexport type JwtPayloadState<TPayload> = {\n jwtPayload: TPayload;\n};\n\nexport type JwtMiddlewareUnit<TPayload> = MiddlewareUnit<\n MiddlewareReturnFromParts<unknown, unknown, unknown, JwtPayloadState<TPayload>>\n>;\n\nexport type JwtOptions = Parameters<typeof honoJwt>[0];\n\n/**\n * JWT auth middleware. Invalid or missing tokens return **401** (Hono).\n * Successfully decoded payload is placed in `ctx.state.jwtPayload`.\n */\nexport function jwt<TPayload = Record<string, unknown>>(\n options: JwtOptions,\n): JwtMiddlewareUnit<TPayload> {\n const mw = honoMw(honoJwt(options));\n return middleware<JwtPayloadState<TPayload>>((ctx, next) =>\n mw(ctx, async () => {\n const payload = (ctx as unknown as { var: { jwtPayload?: unknown } }).var.jwtPayload;\n return next({ jwtPayload: payload as TPayload });\n }),\n );\n}\n"],"mappings":";;;;;;;;AAoBA,SAAgB,IACd,SAC6B;CAC7B,MAAM,KAAK,OAAO,MAAQ,OAAO,CAAC;CAClC,OAAO,YAAuC,KAAK,SACjD,GAAG,KAAK,YAAY;EAClB,MAAM,UAAW,IAAqD,IAAI;EAC1E,OAAO,KAAK,EAAE,YAAY,QAAoB,CAAC;CACjD,CAAC,CACH;AACF"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { secureHeaders as honoSecureHeaders } from 'hono/secure-headers';
|
|
2
|
-
export declare function secureHeaders(...args: Parameters<typeof honoSecureHeaders>): import('../types/units.js').DefineMiddlewareResult<unknown, unknown, unknown, {}, Promise<Response>, unknown, unknown, unknown, {}, null, {}>;
|
|
3
|
-
export type SecureHeadersOptions = NonNullable<Parameters<typeof honoSecureHeaders>[0]>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { middleware } from "../define/middleware.js";
|
|
2
|
-
import { honoMw } from "./hono-mw.js";
|
|
3
|
-
import { secureHeaders as secureHeaders$1 } from "hono/secure-headers";
|
|
4
|
-
//#region src/middleware/secure-headers.ts
|
|
5
|
-
function secureHeaders(...args) {
|
|
6
|
-
return middleware(honoMw(secureHeaders$1(...args)));
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { secureHeaders };
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=secure-headers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secure-headers.js","names":[],"sources":["../../../src/middleware/secure-headers.ts"],"sourcesContent":["import { secureHeaders as honoSecureHeaders } from \"hono/secure-headers\";\n\nimport { middleware } from \"../define/middleware.js\";\nimport { honoMw } from \"./hono-mw.js\";\n\nexport function secureHeaders(...args: Parameters<typeof honoSecureHeaders>) {\n return middleware(honoMw(honoSecureHeaders(...args)));\n}\n\nexport type SecureHeadersOptions = NonNullable<Parameters<typeof honoSecureHeaders>[0]>;\n"],"mappings":";;;;AAKA,SAAgB,cAAc,GAAG,MAA4C;CAC3E,OAAO,WAAW,OAAO,gBAAkB,GAAG,IAAI,CAAC,CAAC;AACtD"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { timing as honoTiming } from 'hono/timing';
|
|
2
|
-
export declare function timing(...args: Parameters<typeof honoTiming>): import('../types/units.js').DefineMiddlewareResult<unknown, unknown, unknown, {}, Promise<Response>, unknown, unknown, unknown, {}, null, {}>;
|
|
3
|
-
export type TimingOptions = NonNullable<Parameters<typeof honoTiming>[0]>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { middleware } from "../define/middleware.js";
|
|
2
|
-
import { honoMw } from "./hono-mw.js";
|
|
3
|
-
import { timing as timing$1 } from "hono/timing";
|
|
4
|
-
//#region src/middleware/timing.ts
|
|
5
|
-
function timing(...args) {
|
|
6
|
-
return middleware(honoMw(timing$1(...args)));
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { timing };
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=timing.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timing.js","names":[],"sources":["../../../src/middleware/timing.ts"],"sourcesContent":["import { timing as honoTiming } from \"hono/timing\";\n\nimport { middleware } from \"../define/middleware.js\";\nimport { honoMw } from \"./hono-mw.js\";\n\nexport function timing(...args: Parameters<typeof honoTiming>) {\n return middleware(honoMw(honoTiming(...args)));\n}\n\nexport type TimingOptions = NonNullable<Parameters<typeof honoTiming>[0]>;\n"],"mappings":";;;;AAKA,SAAgB,OAAO,GAAG,MAAqC;CAC7D,OAAO,WAAW,OAAO,SAAW,GAAG,IAAI,CAAC,CAAC;AAC/C"}
|
package/dist/esm/reply.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@taserjs/router-utils/reply';
|
package/dist/esm/reply.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@taserjs/router-utils/reply";
|
package/dist/esm/stream.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@taserjs/router-utils/stream';
|
package/dist/esm/stream.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@taserjs/router-utils/stream";
|
package/dist/esm/types/app.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { CookieRuntimeConfig, RouteManifestShape } from '@taserjs/router-core';
|
|
2
|
-
import { ResponseValidationFailureHandler } from '@taserjs/router-utils';
|
|
3
|
-
import { TaserApp } from '../builder/app.js';
|
|
4
|
-
import { ReturnsMap } from './returns.js';
|
|
5
|
-
import { Schema } from './schema.js';
|
|
6
|
-
export type CreateTaserAppOptions = {
|
|
7
|
-
response?: {
|
|
8
|
-
/** Validate handler replies against returns maps. Default true. */
|
|
9
|
-
validate?: boolean;
|
|
10
|
-
onValidationFailure?: ResponseValidationFailureHandler;
|
|
11
|
-
};
|
|
12
|
-
/** Global cookie defaults and signing secret. Per-call `ctx.cookies.set` options override defaults. */
|
|
13
|
-
cookies?: CookieRuntimeConfig;
|
|
14
|
-
};
|
|
15
|
-
export type ContextDefinition<TBoot extends Record<string, unknown> = Record<string, never>, TReq extends Record<string, unknown> = Record<string, never>> = {
|
|
16
|
-
boot?: () => TBoot | Promise<TBoot>;
|
|
17
|
-
request?: (req: Request) => TReq | Promise<TReq>;
|
|
18
|
-
};
|
|
19
|
-
export type InferAppContext<T extends ContextDefinition<Record<string, unknown>, Record<string, unknown>>> = T extends ContextDefinition<infer TBoot, infer TReq> ? TBoot & TReq : Record<string, never>;
|
|
20
|
-
export type OnErrorOptions<TResponses extends ReturnsMap = ReturnsMap> = {
|
|
21
|
-
responses?: TResponses;
|
|
22
|
-
handle: (error: unknown, ctx?: unknown) => Response | Promise<Response>;
|
|
23
|
-
};
|
|
24
|
-
export type InferAppManifest<TApp> = TApp extends TaserApp<infer TManifest, any> ? TManifest : TApp extends {
|
|
25
|
-
manifest: infer TManifest;
|
|
26
|
-
} ? TManifest : TApp extends RouteManifestShape ? TApp : never;
|
|
27
|
-
export type { RouteManifestShape } from '@taserjs/router-core';
|
|
28
|
-
export type { Schema };
|
|
29
|
-
export type { TaserApp } from '../builder/app.js';
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
import { Awaitable, TaserCookieJar, TaserHeaders } from '@taserjs/router-core';
|
|
2
|
-
import { RouterMiddlewaresRegister, RouterRegister, RouterRoutesRegister } from '../index.js';
|
|
3
|
-
import { MergeMiddlewareField, MergeMiddlewareInputField, MergePart, RequestShape, Simplify, UnionToIntersection, UnitRuntimeContext } from './type-utils.js';
|
|
4
|
-
import { ReturnsMap, ValidHandlerReply } from './returns.js';
|
|
5
|
-
import { Schema } from './schema.js';
|
|
6
|
-
import { EmptyAppContext, ExtractState, Method, MiddlewareDefinition, MiddlewareRequirements, MiddlewareReturnFromParts, MiddlewareUnit, NextFn, ValidatorParts } from './units.js';
|
|
7
|
-
export type { Awaitable } from '@taserjs/router-core';
|
|
8
|
-
export type { SchemaRequestShape, InferInput, InferOutput, Schema, StandardSchemaV1, } from './schema.js';
|
|
9
|
-
export type { MergeMiddlewareField, MergeMiddlewareInputField, MergePart, RequestShape, Simplify, UnitRuntimeContext, UnwrapPart, } from './type-utils.js';
|
|
10
|
-
export type { EmptyReturns, EnforceHandlerReply, HandlerReply, HasReturns, MergeReturns, ReplyFor, ReturnsMap, StatusCode, ValidHandlerReply, } from './returns.js';
|
|
11
|
-
export type { EmptyAppContext, ExtractState, HttpMethod, IsUnknown, Method, MiddlewareDefinition, MiddlewareRequirements, MiddlewareReturnFromParts, MiddlewareUnit, MiddlewareUnitBuilder, NextFn, NextResult, StandaloneMiddlewareContext, StateBrand, ValidatorParts, } from './units.js';
|
|
12
|
-
export type AppContext = RouterRegister extends {
|
|
13
|
-
AppContext: infer C;
|
|
14
|
-
} ? C : EmptyAppContext;
|
|
15
|
-
export type RoutePath = RouterRegister extends {
|
|
16
|
-
RoutePath: infer P;
|
|
17
|
-
} ? P : never;
|
|
18
|
-
export type LayoutId = RouterRegister extends {
|
|
19
|
-
LayoutId: infer L;
|
|
20
|
-
} ? L : never;
|
|
21
|
-
export type LayoutTree = RouterRegister extends {
|
|
22
|
-
LayoutTree: infer T;
|
|
23
|
-
} ? T : Record<never, never>;
|
|
24
|
-
export type LayoutMiddlewaresMap = RouterMiddlewaresRegister extends {
|
|
25
|
-
LayoutMiddlewares: infer M;
|
|
26
|
-
} ? M : RouterRegister extends {
|
|
27
|
-
LayoutMiddlewares: infer M;
|
|
28
|
-
} ? M : Record<never, never>;
|
|
29
|
-
export type RouteByPathMethod = RouterRoutesRegister extends {
|
|
30
|
-
RouteByPathMethod: infer R;
|
|
31
|
-
} ? R : RouterRegister extends {
|
|
32
|
-
RouteByPathMethod: infer R;
|
|
33
|
-
} ? R : Record<never, never>;
|
|
34
|
-
export type LayoutBuilder<TAppContext extends Record<string, unknown> = AppContext> = <const Layout extends LayoutId>(layout: Layout) => MiddlewareBuilder<Layout, readonly [], TAppContext>;
|
|
35
|
-
type ParseParam<Segment extends string> = Segment extends "*" ? {
|
|
36
|
-
_splat: string;
|
|
37
|
-
} : Segment extends `:${infer Name extends string}` ? Name extends "" ? {} : {
|
|
38
|
-
[K in Name]: string;
|
|
39
|
-
} : {};
|
|
40
|
-
type ParseParamsFromSegments<S extends string> = S extends `${infer Segment}/${infer Rest}` ? ParseParam<Segment> & ParseParamsFromSegments<Rest> : ParseParam<S>;
|
|
41
|
-
export type PathParams<Path extends string> = Path extends `/${infer Rest}` ? ParseParamsFromSegments<Rest> : ParseParamsFromSegments<Path>;
|
|
42
|
-
export type LayoutParams<Layout extends string> = PathParams<Layout>;
|
|
43
|
-
export type ResolveParams<TPathParams, TSchemaParams> = TSchemaParams extends Record<string, unknown> ? [keyof TSchemaParams] extends [never] ? TPathParams : Simplify<Omit<TPathParams, keyof TSchemaParams> & TSchemaParams> : TPathParams;
|
|
44
|
-
type LayoutParent<Layout extends LayoutId> = Layout extends keyof LayoutTree ? LayoutTree[Layout] extends {
|
|
45
|
-
parent: infer P extends LayoutId;
|
|
46
|
-
} ? P : null : null;
|
|
47
|
-
type LayoutMiddlewares<Layout extends LayoutId> = [Layout] extends [keyof LayoutMiddlewaresMap] ? LayoutMiddlewaresMap[Layout] extends {
|
|
48
|
-
readonly __acc?: infer Acc extends readonly unknown[];
|
|
49
|
-
} ? Acc : LayoutMiddlewaresMap[Layout] extends readonly unknown[] ? LayoutMiddlewaresMap[Layout] : readonly [] : readonly [];
|
|
50
|
-
type ResolveLayoutMiddlewares<Layout extends LayoutId | null, Depth extends readonly unknown[] = []> = Depth["length"] extends 10 ? readonly [] : [Layout] extends [LayoutId] ? LayoutParent<Layout> extends infer Parent extends LayoutId ? readonly [
|
|
51
|
-
...ResolveLayoutMiddlewares<Parent, [...Depth, unknown]>,
|
|
52
|
-
...LayoutMiddlewares<Layout>
|
|
53
|
-
] : readonly [...LayoutMiddlewares<Layout>] : readonly [];
|
|
54
|
-
export type ResolveLayoutIdChain<L extends LayoutId | null, Depth extends readonly unknown[] = []> = Depth["length"] extends 10 ? readonly [] : L extends LayoutId ? readonly [...ResolveLayoutIdChain<LayoutParent<L>, [...Depth, unknown]>, L] : readonly [];
|
|
55
|
-
export type ResolveLayoutMiddlewaresState<Layout extends LayoutId | null> = Layout extends LayoutId ? MergeMiddlewareField<ResolveLayoutMiddlewares<Layout>, "state"> : {};
|
|
56
|
-
export type ResolveLayoutsState<Layouts extends LayoutId | readonly LayoutId[]> = Layouts extends LayoutId ? ResolveLayoutMiddlewaresState<Layouts> : Layouts extends readonly LayoutId[] ? UnionToIntersection<Layouts[number] extends infer L extends LayoutId ? ResolveLayoutMiddlewaresState<L> : never> : {};
|
|
57
|
-
/** Fold layout middleware Acc from a route's layoutChain (shallow → deep). */
|
|
58
|
-
type ResolveLayoutChainMiddlewares<Chain extends readonly LayoutId[]> = Chain extends readonly [
|
|
59
|
-
infer Head extends LayoutId,
|
|
60
|
-
...infer Rest
|
|
61
|
-
] ? readonly [
|
|
62
|
-
...LayoutMiddlewares<Head>,
|
|
63
|
-
...ResolveLayoutChainMiddlewares<Rest extends readonly LayoutId[] ? Rest : readonly []>
|
|
64
|
-
] : readonly [];
|
|
65
|
-
type RouteEntry<Path extends RoutePath, TMethod extends Method> = RouteByPathMethod[Path] extends {
|
|
66
|
-
[K in TMethod]: infer Entry;
|
|
67
|
-
} ? Entry : never;
|
|
68
|
-
type RouteLayoutChain<Path extends RoutePath, TMethod extends Method> = RouteEntry<Path, TMethod> extends {
|
|
69
|
-
layouts: infer Chain extends readonly LayoutId[];
|
|
70
|
-
} ? Chain : readonly [];
|
|
71
|
-
export type RouteLayoutMiddlewares<Path extends RoutePath, TMethod extends Method> = ResolveLayoutChainMiddlewares<RouteLayoutChain<Path, TMethod>>;
|
|
72
|
-
export type RouteLayoutField<Path extends RoutePath, TMethod extends Method, Field extends "query" | "params" | "body" | "state"> = MergeMiddlewareField<RouteLayoutMiddlewares<Path, TMethod>, Field>;
|
|
73
|
-
export type RouteLayoutInputField<Path extends RoutePath, TMethod extends Method, Field extends "query" | "params" | "body"> = MergeMiddlewareInputField<RouteLayoutMiddlewares<Path, TMethod>, Field>;
|
|
74
|
-
type RouteResolvedField<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[], Field extends "query" | "params" | "body" | "state"> = RouteLayoutField<Path, TMethod, Field> & MergeMiddlewareField<Acc, Field>;
|
|
75
|
-
export type RouteChainContext<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[], TQuery, TParams, TBody, TAppContext extends Record<string, unknown> = AppContext> = Simplify<TAppContext & UnitRuntimeContext & {
|
|
76
|
-
query: MergePart<TQuery, RouteResolvedField<Path, TMethod, Acc, "query">>;
|
|
77
|
-
params: ResolveParams<PathParams<Path>, MergePart<TParams, RouteResolvedField<Path, TMethod, Acc, "params">>>;
|
|
78
|
-
body: MergePart<TBody, RouteResolvedField<Path, TMethod, Acc, "body">>;
|
|
79
|
-
state: RouteResolvedField<Path, TMethod, Acc, "state">;
|
|
80
|
-
headers: TaserHeaders;
|
|
81
|
-
cookies: TaserCookieJar;
|
|
82
|
-
}>;
|
|
83
|
-
export type RouteHandleContext<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[], Validators extends {
|
|
84
|
-
query?: unknown;
|
|
85
|
-
params?: unknown;
|
|
86
|
-
body?: unknown;
|
|
87
|
-
}, TAppContext extends Record<string, unknown> = AppContext> = Simplify<TAppContext & UnitRuntimeContext & {
|
|
88
|
-
path: Path;
|
|
89
|
-
method: TMethod;
|
|
90
|
-
query: Simplify<MergePart<Validators extends {
|
|
91
|
-
query?: infer Q;
|
|
92
|
-
} ? Q : unknown, RouteResolvedField<Path, TMethod, Acc, "query">>>;
|
|
93
|
-
params: Simplify<ResolveParams<PathParams<Path>, MergePart<Validators extends {
|
|
94
|
-
params?: infer P;
|
|
95
|
-
} ? P : unknown, RouteResolvedField<Path, TMethod, Acc, "params">>>>;
|
|
96
|
-
body: Simplify<MergePart<Validators extends {
|
|
97
|
-
body?: infer B;
|
|
98
|
-
} ? B : unknown, RouteResolvedField<Path, TMethod, Acc, "body">>>;
|
|
99
|
-
state: Simplify<RouteResolvedField<Path, TMethod, Acc, "state">>;
|
|
100
|
-
headers: TaserHeaders;
|
|
101
|
-
cookies: TaserCookieJar;
|
|
102
|
-
}>;
|
|
103
|
-
export type RouteHandleContextWithoutBody<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[], Validators extends {
|
|
104
|
-
query?: unknown;
|
|
105
|
-
params?: unknown;
|
|
106
|
-
}, TAppContext extends Record<string, unknown> = AppContext> = Simplify<TAppContext & UnitRuntimeContext & {
|
|
107
|
-
path: Path;
|
|
108
|
-
method: TMethod;
|
|
109
|
-
query: Simplify<MergePart<Validators extends {
|
|
110
|
-
query?: infer Q;
|
|
111
|
-
} ? Q : unknown, RouteResolvedField<Path, TMethod, Acc, "query">>>;
|
|
112
|
-
params: Simplify<ResolveParams<PathParams<Path>, MergePart<Validators extends {
|
|
113
|
-
params?: infer P;
|
|
114
|
-
} ? P : unknown, RouteResolvedField<Path, TMethod, Acc, "params">>>>;
|
|
115
|
-
body: never;
|
|
116
|
-
state: Simplify<RouteResolvedField<Path, TMethod, Acc, "state">>;
|
|
117
|
-
headers: TaserHeaders;
|
|
118
|
-
cookies: TaserCookieJar;
|
|
119
|
-
}>;
|
|
120
|
-
type RouteResolvedInputField<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[], Field extends "query" | "params" | "body"> = RouteLayoutInputField<Path, TMethod, Field> & MergeMiddlewareInputField<Acc, Field>;
|
|
121
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
122
|
-
type IsEmptyObject<T> = [keyof T] extends [never] ? true : false;
|
|
123
|
-
export type IsLayoutAllowed<TRequiredLayouts, TChain extends readonly LayoutId[]> = [
|
|
124
|
-
TRequiredLayouts
|
|
125
|
-
] extends [never] ? true : [unknown] extends [TRequiredLayouts] ? true : [null] extends [TRequiredLayouts] ? true : [undefined] extends [TRequiredLayouts] ? true : TRequiredLayouts extends LayoutId ? TRequiredLayouts extends TChain[number] ? true : false : TRequiredLayouts extends readonly LayoutId[] ? [TRequiredLayouts[number] & TChain[number]] extends [never] ? false : true : true;
|
|
126
|
-
export type IsRequirementsSatisfied<TActual extends {
|
|
127
|
-
query?: unknown;
|
|
128
|
-
params?: unknown;
|
|
129
|
-
body?: unknown;
|
|
130
|
-
state?: unknown;
|
|
131
|
-
}, TRequires extends MiddlewareRequirements> = [TRequires] extends [never] ? true : [unknown] extends [TRequires] ? true : [null] extends [TRequires] ? true : [undefined] extends [TRequires] ? true : [IsEmptyObject<TRequires>] extends [true] ? true : (TRequires extends {
|
|
132
|
-
state: infer S extends Record<string, unknown>;
|
|
133
|
-
} ? [TActual["state"]] extends [S] ? true : false : true) extends false ? false : (TRequires extends {
|
|
134
|
-
query: infer Q extends Record<string, unknown>;
|
|
135
|
-
} ? [TActual["query"]] extends [Q] ? true : false : true) extends false ? false : (TRequires extends {
|
|
136
|
-
params: infer P extends Record<string, unknown>;
|
|
137
|
-
} ? [TActual["params"]] extends [P] ? true : false : true) extends false ? false : (TRequires extends {
|
|
138
|
-
body: infer B;
|
|
139
|
-
} ? unknown extends B ? true : [TRequires["body"]] extends [undefined] ? true : [TActual["body"]] extends [B] ? true : false : true) extends false ? false : true;
|
|
140
|
-
export type IsStateSatisfied<TActualState, TRequiredState> = IsRequirementsSatisfied<{
|
|
141
|
-
state: TActualState;
|
|
142
|
-
}, {
|
|
143
|
-
state: TRequiredState extends Record<string, unknown> ? TRequiredState : {};
|
|
144
|
-
}>;
|
|
145
|
-
type InputFacet<T, K extends string> = IsNever<T> extends true ? {} : IsEmptyObject<T> extends true ? {} : {
|
|
146
|
-
[Key in K]: T;
|
|
147
|
-
};
|
|
148
|
-
type RouteQueryInput<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[], Validators extends ValidatorParts> = Simplify<MergePart<RequestShape<Validators extends {
|
|
149
|
-
queryIn?: infer QI;
|
|
150
|
-
} ? QI : unknown, Validators extends {
|
|
151
|
-
query?: infer Q;
|
|
152
|
-
} ? Q : unknown>, RouteResolvedInputField<Path, TMethod, Acc, "query">>>;
|
|
153
|
-
type RouteParamsInput<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[], Validators extends ValidatorParts> = Simplify<ResolveParams<PathParams<Path>, MergePart<RequestShape<Validators extends {
|
|
154
|
-
paramsIn?: infer PI;
|
|
155
|
-
} ? PI : unknown, Validators extends {
|
|
156
|
-
params?: infer P;
|
|
157
|
-
} ? P : unknown>, RouteResolvedInputField<Path, TMethod, Acc, "params">>>>;
|
|
158
|
-
type RouteBodyInput<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[], Validators extends ValidatorParts> = Simplify<MergePart<RequestShape<Validators extends {
|
|
159
|
-
bodyIn?: infer BI;
|
|
160
|
-
} ? BI : unknown, Validators extends {
|
|
161
|
-
body?: infer B;
|
|
162
|
-
} ? B : unknown>, RouteResolvedInputField<Path, TMethod, Acc, "body">>>;
|
|
163
|
-
export type RouteHandleInputWithoutBody<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[], Validators extends ValidatorParts = {}> = Simplify<InputFacet<RouteQueryInput<Path, TMethod, Acc, Validators>, "query"> & InputFacet<RouteParamsInput<Path, TMethod, Acc, Validators>, "params">>;
|
|
164
|
-
export type RouteHandleInput<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[], Validators extends ValidatorParts = {}> = Simplify<RouteHandleInputWithoutBody<Path, TMethod, Acc, Validators> & InputFacet<RouteBodyInput<Path, TMethod, Acc, Validators>, "body">>;
|
|
165
|
-
export type InferRouteInputFromPath<Path extends RoutePath, TMethod extends Method> = RouteEntry<Path, TMethod> extends {
|
|
166
|
-
route: infer Route;
|
|
167
|
-
} ? Route extends {
|
|
168
|
-
$Infer: {
|
|
169
|
-
Input: infer I;
|
|
170
|
-
};
|
|
171
|
-
} ? I : never : never;
|
|
172
|
-
export type MiddlewareLayoutField<Layout extends LayoutId, Field extends "query" | "params" | "body" | "state"> = [LayoutParent<Layout>] extends [infer Parent extends LayoutId] ? MergeMiddlewareField<ResolveLayoutMiddlewares<Parent>, Field> : {};
|
|
173
|
-
type MiddlewareChainField<Layout extends LayoutId, Acc extends readonly unknown[], Field extends "query" | "params" | "body" | "state"> = MiddlewareLayoutField<Layout, Field> & MergeMiddlewareField<Acc, Field>;
|
|
174
|
-
export type MiddlewareChainContext<Layout extends LayoutId, Acc extends readonly unknown[], TQuery = unknown, TParams = unknown, TBody = unknown, TAppContext extends Record<string, unknown> = AppContext> = Simplify<TAppContext & {
|
|
175
|
-
readonly request: Request;
|
|
176
|
-
readonly method: Method;
|
|
177
|
-
readonly url: URL;
|
|
178
|
-
readonly headers: TaserHeaders;
|
|
179
|
-
readonly cookies: TaserCookieJar;
|
|
180
|
-
query: Simplify<MergePart<TQuery, MiddlewareChainField<Layout, Acc, "query">>>;
|
|
181
|
-
params: Simplify<ResolveParams<LayoutParams<Layout>, Simplify<MergePart<TParams, MiddlewareChainField<Layout, Acc, "params">>>>>;
|
|
182
|
-
body: Simplify<MergePart<TBody, MiddlewareChainField<Layout, Acc, "body">>>;
|
|
183
|
-
state: Simplify<MiddlewareChainField<Layout, Acc, "state">>;
|
|
184
|
-
}>;
|
|
185
|
-
export type MiddlewareBuilder<Layout extends LayoutId, Acc extends readonly unknown[] = readonly [], TAppContext extends Record<string, unknown> = AppContext> = {
|
|
186
|
-
readonly layout: Layout;
|
|
187
|
-
readonly middlewares: readonly MiddlewareDefinition[];
|
|
188
|
-
readonly __acc?: Acc;
|
|
189
|
-
use<TAcc, TReturns extends ReturnsMap = {}, TRequiredLayouts = unknown, TRequires extends MiddlewareRequirements = {}>(unit: [
|
|
190
|
-
IsLayoutAllowed<TRequiredLayouts, ResolveLayoutIdChain<Layout>>,
|
|
191
|
-
IsRequirementsSatisfied<{
|
|
192
|
-
query: MiddlewareChainField<Layout, Acc, "query">;
|
|
193
|
-
params: MiddlewareChainField<Layout, Acc, "params">;
|
|
194
|
-
body: MiddlewareChainField<Layout, Acc, "body">;
|
|
195
|
-
state: MiddlewareChainField<Layout, Acc, "state">;
|
|
196
|
-
}, TRequires>
|
|
197
|
-
] extends [true, true] ? MiddlewareUnit<TAcc, TReturns, TRequiredLayouts, TRequires> : never): MiddlewareBuilder<Layout, readonly [...Acc, TAcc], TAppContext>;
|
|
198
|
-
use<R = unknown>(fn: (ctx: Simplify<TAppContext & {
|
|
199
|
-
readonly request: Request;
|
|
200
|
-
readonly method: Method;
|
|
201
|
-
readonly url: URL;
|
|
202
|
-
readonly headers: TaserHeaders;
|
|
203
|
-
readonly cookies: TaserCookieJar;
|
|
204
|
-
query: Simplify<MergePart<unknown, MiddlewareChainField<Layout, Acc, "query">>>;
|
|
205
|
-
params: Simplify<ResolveParams<LayoutParams<Layout>, Simplify<MergePart<unknown, MiddlewareChainField<Layout, Acc, "params">>>>>;
|
|
206
|
-
body: Simplify<MergePart<unknown, MiddlewareChainField<Layout, Acc, "body">>>;
|
|
207
|
-
state: Simplify<MiddlewareChainField<Layout, Acc, "state">>;
|
|
208
|
-
}>, next: NextFn) => Awaitable<R>): MiddlewareBuilder<Layout, readonly [...Acc, MiddlewareReturnFromParts<unknown, unknown, unknown, ExtractState<R>>], TAppContext>;
|
|
209
|
-
};
|
|
210
|
-
export type RouteExport<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[], TReturns extends ReturnsMap = {}, TOutput = Response> = {
|
|
211
|
-
readonly path: Path;
|
|
212
|
-
readonly method: TMethod | "ANY" | "ALL";
|
|
213
|
-
readonly methods?: readonly Method[];
|
|
214
|
-
readonly middlewares: readonly MiddlewareDefinition[];
|
|
215
|
-
readonly __acc?: Acc;
|
|
216
|
-
readonly returns?: TReturns;
|
|
217
|
-
readonly bodyMode?: "json" | "form" | "urlencoded";
|
|
218
|
-
handler: (ctx: unknown) => Awaitable<Response>;
|
|
219
|
-
readonly $Infer: {
|
|
220
|
-
Context: TMethod extends "GET" | "DELETE" | "HEAD" | "OPTIONS" ? RouteHandleContextWithoutBody<Path, TMethod, Acc, {}> : RouteHandleContext<Path, TMethod, Acc, {}>;
|
|
221
|
-
Input: TMethod extends "GET" | "DELETE" | "HEAD" | "OPTIONS" ? RouteHandleInputWithoutBody<Path, TMethod, Acc, {}> : RouteHandleInput<Path, TMethod, Acc, {}>;
|
|
222
|
-
Output: TOutput;
|
|
223
|
-
};
|
|
224
|
-
query?: Schema<unknown>;
|
|
225
|
-
params?: Schema<unknown>;
|
|
226
|
-
body?: Schema<unknown>;
|
|
227
|
-
};
|
|
228
|
-
type RouteHandleResult<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[], Validators extends ValidatorParts, TReturns extends ReturnsMap = {}, TOutput = Response, TAppContext extends Record<string, unknown> = AppContext> = Omit<RouteExport<Path, TMethod, Acc, TReturns, TOutput>, "$Infer"> & {
|
|
229
|
-
readonly $Infer: {
|
|
230
|
-
Context: TMethod extends "GET" | "DELETE" | "HEAD" | "OPTIONS" ? RouteHandleContextWithoutBody<Path, TMethod, Acc, Validators, TAppContext> : RouteHandleContext<Path, TMethod, Acc, Validators, TAppContext>;
|
|
231
|
-
Input: TMethod extends "GET" | "DELETE" | "HEAD" | "OPTIONS" ? RouteHandleInputWithoutBody<Path, TMethod, Acc, Validators> : RouteHandleInput<Path, TMethod, Acc, Validators>;
|
|
232
|
-
Output: TOutput;
|
|
233
|
-
};
|
|
234
|
-
};
|
|
235
|
-
export type RouteContractBuilderBase<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[] = readonly [], Validators extends ValidatorParts = {}, TReturns extends ReturnsMap = {}, TAppContext extends Record<string, unknown> = AppContext> = {
|
|
236
|
-
readonly path: Path;
|
|
237
|
-
readonly method: TMethod;
|
|
238
|
-
readonly $Infer: {
|
|
239
|
-
Context: TMethod extends "GET" | "DELETE" | "HEAD" | "OPTIONS" ? RouteHandleContextWithoutBody<Path, TMethod, Acc, Validators, TAppContext> : RouteHandleContext<Path, TMethod, Acc, Validators, TAppContext>;
|
|
240
|
-
Input: TMethod extends "GET" | "DELETE" | "HEAD" | "OPTIONS" ? RouteHandleInputWithoutBody<Path, TMethod, Acc, Validators> : RouteHandleInput<Path, TMethod, Acc, Validators>;
|
|
241
|
-
Output: TReturns;
|
|
242
|
-
};
|
|
243
|
-
query<TQuery, TQueryIn = unknown>(schema: Schema<TQuery, TQueryIn>): RouteContractBuilder<Path, TMethod, Acc, Omit<Validators, "query" | "queryIn"> & {
|
|
244
|
-
query: TQuery;
|
|
245
|
-
queryIn: TQueryIn;
|
|
246
|
-
}, TReturns, TAppContext>;
|
|
247
|
-
params<TParams, TParamsIn = unknown>(schema: Schema<TParams, TParamsIn>): RouteContractBuilder<Path, TMethod, Acc, Omit<Validators, "params" | "paramsIn"> & {
|
|
248
|
-
params: TParams;
|
|
249
|
-
paramsIn: TParamsIn;
|
|
250
|
-
}, TReturns, TAppContext>;
|
|
251
|
-
returns<const M extends ReturnsMap>(map: M): RouteContractBuilder<Path, TMethod, Acc, Validators, Omit<TReturns, keyof M> & M, TAppContext>;
|
|
252
|
-
handler<R extends Response = Response>(fn: (ctx: TMethod extends "GET" | "DELETE" | "HEAD" | "OPTIONS" ? RouteHandleContextWithoutBody<Path, TMethod, Acc, Validators, TAppContext> : RouteHandleContext<Path, TMethod, Acc, Validators, TAppContext>) => Awaitable<R>, ..._assert: [R] extends [ValidHandlerReply<R, TReturns>] ? [] : [
|
|
253
|
-
{
|
|
254
|
-
expected: ValidHandlerReply<R, TReturns>;
|
|
255
|
-
actual: R;
|
|
256
|
-
}
|
|
257
|
-
]): RouteHandleResult<Path, TMethod, Acc, Validators, TReturns, R, TAppContext>;
|
|
258
|
-
};
|
|
259
|
-
export type RouteContractBuilder<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[] = readonly [], Validators extends ValidatorParts = {}, TReturns extends ReturnsMap = {}, TAppContext extends Record<string, unknown> = AppContext> = RouteContractBuilderBase<Path, TMethod, Acc, Validators, TReturns, TAppContext> & (TMethod extends "GET" | "DELETE" | "HEAD" | "OPTIONS" ? {} : {
|
|
260
|
-
body<TBody, TBodyIn = unknown>(schema: Schema<TBody, TBodyIn>): RouteContractBuilder<Path, TMethod, Acc, Omit<Validators, "body" | "bodyIn"> & {
|
|
261
|
-
body: TBody;
|
|
262
|
-
bodyIn: TBodyIn;
|
|
263
|
-
}, TReturns, TAppContext>;
|
|
264
|
-
body<Mode extends "json" | "form" | "urlencoded", TBody, TBodyIn = unknown>(mode: Mode, schema: Schema<TBody, TBodyIn>): RouteContractBuilder<Path, TMethod, Acc, Omit<Validators, "body" | "bodyIn"> & {
|
|
265
|
-
body: TBody;
|
|
266
|
-
bodyIn: TBodyIn;
|
|
267
|
-
}, TReturns, TAppContext>;
|
|
268
|
-
});
|
|
269
|
-
export type RouteMiddlewareBuilder<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[] = readonly [], Validators extends ValidatorParts = {}, TReturns extends ReturnsMap = {}, TAppContext extends Record<string, unknown> = AppContext> = RouteContractBuilder<Path, TMethod, Acc, Validators, TReturns, TAppContext> & {
|
|
270
|
-
use<TAcc, UReturns extends ReturnsMap = {}, TRequiredLayouts = unknown, TRequires extends MiddlewareRequirements = {}>(unit: [
|
|
271
|
-
IsLayoutAllowed<TRequiredLayouts, RouteLayoutChain<Path, TMethod>>,
|
|
272
|
-
IsRequirementsSatisfied<{
|
|
273
|
-
query: RouteResolvedField<Path, TMethod, Acc, "query">;
|
|
274
|
-
params: ResolveParams<PathParams<Path>, RouteResolvedField<Path, TMethod, Acc, "params">>;
|
|
275
|
-
body: RouteResolvedField<Path, TMethod, Acc, "body">;
|
|
276
|
-
state: RouteResolvedField<Path, TMethod, Acc, "state">;
|
|
277
|
-
}, TRequires>
|
|
278
|
-
] extends [true, true] ? MiddlewareUnit<TAcc, UReturns, TRequiredLayouts, TRequires> : never): RouteMiddlewareBuilder<Path, TMethod, readonly [...Acc, TAcc], Validators, Omit<TReturns, keyof UReturns> & UReturns, TAppContext>;
|
|
279
|
-
use<R = unknown>(fn: (ctx: RouteChainContext<Path, TMethod, Acc, unknown, unknown, unknown, TAppContext>, next: NextFn) => Awaitable<R>): RouteMiddlewareBuilder<Path, TMethod, readonly [...Acc, MiddlewareReturnFromParts<unknown, unknown, unknown, ExtractState<R>>], Validators, TReturns, TAppContext>;
|
|
280
|
-
};
|
|
281
|
-
export type RouteBuilder<Path extends RoutePath, TMethod extends Method, Acc extends readonly unknown[] = readonly [], Validators extends ValidatorParts = {}, TReturns extends ReturnsMap = {}, TAppContext extends Record<string, unknown> = AppContext> = RouteMiddlewareBuilder<Path, TMethod, Acc, Validators, TReturns, TAppContext>;
|
|
282
|
-
export type RouteDefinition<Path extends RoutePath = RoutePath, TMethod extends Method = Method, Acc extends readonly unknown[] = readonly unknown[], Validators extends ValidatorParts = ValidatorParts, TReturns extends ReturnsMap = ReturnsMap, TOutput = Response, TAppContext extends Record<string, unknown> = AppContext> = RouteHandleResult<Path, TMethod, Acc, Validators, TReturns, TOutput, TAppContext>;
|
|
283
|
-
export type InferRouteContext<R> = R extends {
|
|
284
|
-
$Infer: {
|
|
285
|
-
Context: infer C;
|
|
286
|
-
};
|
|
287
|
-
} ? C : never;
|
|
288
|
-
export type InferRouteInput<R> = R extends {
|
|
289
|
-
$Infer: {
|
|
290
|
-
Input: infer I;
|
|
291
|
-
};
|
|
292
|
-
} ? I : never;
|
|
293
|
-
export type InferRouteOutput<R> = R extends {
|
|
294
|
-
$Infer: {
|
|
295
|
-
Output: infer O;
|
|
296
|
-
};
|
|
297
|
-
} ? O : never;
|