@fougere/http 0.9.3-alpha.0 → 0.10.0-alpha.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/express.d.ts +1 -2
- package/dist/express.d.ts.map +1 -1
- package/dist/express.js +4 -4
- package/dist/express.js.map +1 -1
- package/dist/fastify.d.ts +1 -1
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fastify.js.map +1 -1
- package/dist/hono.d.ts +1 -4
- package/dist/hono.d.ts.map +1 -1
- package/dist/hono.js +2 -4
- package/dist/hono.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/router/Handler.d.ts +4 -0
- package/dist/router/Handler.d.ts.map +1 -0
- package/dist/router/Handler.js +2 -0
- package/dist/router/Handler.js.map +1 -0
- package/dist/router/HttpMethod.d.ts +2 -0
- package/dist/router/HttpMethod.d.ts.map +1 -0
- package/dist/router/HttpMethod.js +2 -0
- package/dist/router/HttpMethod.js.map +1 -0
- package/dist/router/HttpRouter.d.ts +19 -0
- package/dist/router/HttpRouter.d.ts.map +1 -0
- package/dist/router/HttpRouter.js +11 -0
- package/dist/router/HttpRouter.js.map +1 -0
- package/dist/router/MalformedJsonError.d.ts +5 -0
- package/dist/router/MalformedJsonError.d.ts.map +1 -0
- package/dist/router/MalformedJsonError.js +8 -0
- package/dist/router/MalformedJsonError.js.map +1 -0
- package/dist/router/Middleware.d.ts +5 -0
- package/dist/router/Middleware.d.ts.map +1 -0
- package/dist/router/Middleware.js +2 -0
- package/dist/router/Middleware.js.map +1 -0
- package/dist/router/Next.d.ts +5 -0
- package/dist/router/Next.d.ts.map +1 -0
- package/dist/router/Next.js +3 -0
- package/dist/router/Next.js.map +1 -0
- package/dist/router/RequestContext.d.ts +13 -0
- package/dist/router/RequestContext.d.ts.map +1 -0
- package/dist/router/RequestContext.js +2 -0
- package/dist/router/RequestContext.js.map +1 -0
- package/dist/router/ResponseResult.d.ts +8 -0
- package/dist/router/ResponseResult.d.ts.map +1 -0
- package/dist/router/ResponseResult.js +2 -0
- package/dist/router/ResponseResult.js.map +1 -0
- package/package.json +1 -1
- package/src/express.ts +9 -3
- package/src/fastify.ts +7 -2
- package/src/hono.ts +8 -5
- package/src/index.ts +8 -10
- package/src/logger.ts +1 -1
- package/src/router/Handler.ts +4 -0
- package/src/router/HttpMethod.ts +1 -0
- package/src/router/HttpRouter.ts +33 -0
- package/src/router/MalformedJsonError.ts +7 -0
- package/src/router/Middleware.ts +5 -0
- package/src/router/Next.ts +6 -0
- package/src/router/RequestContext.ts +13 -0
- package/src/router/ResponseResult.ts +7 -0
- package/dist/router.d.ts +0 -43
- package/dist/router.d.ts.map +0 -1
- package/dist/router.js +0 -21
- package/dist/router.js.map +0 -1
- package/src/router.ts +0 -66
package/dist/express.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { type HttpRouter } from './router.js';
|
|
1
|
+
import { type HttpRouter } from './router/HttpRouter.js';
|
|
3
2
|
interface ExpressLike {
|
|
4
3
|
use(...handlers: Function[]): void;
|
|
5
4
|
get(path: string, handler: Function): void;
|
package/dist/express.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AAGA,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAMhE,UAAU,WAAW;IACnB,GAAG,CAAC,GAAG,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IACnC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3C,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC5C,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3C,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC7C,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC/C;AAeD,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBrD;AAED,8DAA8D;AAC9D,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAqB1D;AAoDD,qDAAqD;AACrD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,WAAW,GAAG,UAAU,CAuChE"}
|
package/dist/express.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { MalformedJsonError
|
|
1
|
+
import { chain } from './router/HttpRouter.js';
|
|
2
|
+
import { MalformedJsonError } from './router/MalformedJsonError.js';
|
|
3
3
|
const METHOD_MAP = {
|
|
4
4
|
GET: 'get',
|
|
5
5
|
POST: 'post',
|
|
@@ -7,7 +7,7 @@ const METHOD_MAP = {
|
|
|
7
7
|
PATCH: 'patch',
|
|
8
8
|
DELETE: 'delete',
|
|
9
9
|
};
|
|
10
|
-
// Core declares this cap (`wire/call.ts`) and three
|
|
10
|
+
// Core declares this cap (`wire/call.ts`) and three facades read it there. This package
|
|
11
11
|
// declares NO Fougere dependency — a leaf port does not take one on the kernel for a
|
|
12
12
|
// number — so it keeps the fourth copy, deliberately.
|
|
13
13
|
const MAX_BODY_BYTES = 1024 * 1024;
|
|
@@ -43,7 +43,7 @@ export function readExpressBody(req) {
|
|
|
43
43
|
return {};
|
|
44
44
|
// `null` is parsed JSON, not evidence that no parser ran. Falling through here
|
|
45
45
|
// turned an explicit domain value into `{}` (or tried to drain an already consumed
|
|
46
|
-
// stream), while every other
|
|
46
|
+
// stream), while every other facade kept it.
|
|
47
47
|
if (req.body !== undefined)
|
|
48
48
|
return req.body;
|
|
49
49
|
const contentType = String(req.headers?.['content-type'] ?? '');
|
package/dist/express.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"express.js","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAmB,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAcpE,MAAM,UAAU,GAAoE;IAClF,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,wFAAwF;AACxF,qFAAqF;AACrF,sDAAsD;AACtD,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnC,6EAA6E;AAC7E,MAAM,UAAU,WAAW,CAAC,GAAQ;IAClC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YAC/B,IAAI,QAAQ;gBAAE,OAAO;YACrB,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC;YACrB,IAAI,IAAI,GAAG,cAAc,EAAE,CAAC;gBAC1B,QAAQ,GAAG,IAAI,CAAC;gBAChB,MAAM,CAAC,MAAM,C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AAE,GAAG,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,mBAAmB,EAAE,EAAE,CAAC,CAAC;wBACtG,OAAO;oBACT,CAAC;oBACD,0EAA0E;oBAC1E,qEAAqE;oBACrE,IAAI,CAAC,GAAG,CAAC,CAAC;gBACZ,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/fastify.d.ts
CHANGED
package/dist/fastify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKzD,UAAU,WAAW;IACnB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC/C,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3C,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC5C,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3C,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC7C,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC/C;AAoDD,uDAAuD;AACvD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,CAyBnE"}
|
package/dist/fastify.js
CHANGED
package/dist/fastify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastify.js","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"fastify.js","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAiB/C,MAAM,UAAU,GAAoE;IAClF,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,SAAS,YAAY,CAAC,GAAQ;IAC5B,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IACxC,IAAI,OAA4B,CAAC;IAEjC,OAAO;QACL,8EAA8E;QAC9E,yEAAyE;QACzE,IAAI,OAAO;YACT,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,QAAQ,IAAI,MAAM,MAAM,GAAG,CAAC,QAAQ,IAAI,WAAW,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;gBACnF,MAAM,OAAO,GAAG,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,MAAM,CAAC;gBACtD,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE;oBACzB,MAAM;oBACN,OAAO,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,OAAiC,CAAC;oBAC3D,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACjF,CAAC,CAAC;YACL,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM,EAAE,MAAoB;QAC5B,IA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OAAqB,EAAE,CAAC,CAAC;YAC9E,CAAC;iBAAM,CAAC;gBACN,iBAAiB,CAAC,IAAI,CAAC,QAAsB,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;QAED,EAAE,CAAC,MAAkB,EAAE,IAAY,EAAE,OAAgB;YACnD,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;YAC7B,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,GAAQ,EAAE,KAAU,EAAE,EAAE;gBAC7C,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;gBAC9B,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;gBAC/E,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YAC9B,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/hono.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Hono adapter — bridges a Hono app to the HttpRouter interface.
|
|
3
|
-
*/
|
|
4
|
-
import { type HttpRouter } from './router.js';
|
|
1
|
+
import { type HttpRouter } from './router/HttpRouter.js';
|
|
5
2
|
interface HonoLike {
|
|
6
3
|
use(path: string, ...handlers: Function[]): void;
|
|
7
4
|
use(...handlers: Function[]): void;
|
package/dist/hono.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../src/hono.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../src/hono.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOzD,UAAU,QAAQ;IAChB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IACjD,GAAG,CAAC,GAAG,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IACnC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3C,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC5C,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3C,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC7C,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC/C;AAyDD,iDAAiD;AACjD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,QAAQ,GAAG,UAAU,CAiD1D"}
|
package/dist/hono.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { MalformedJsonError, PASSTHROUGH, } from './router.js';
|
|
1
|
+
import { MalformedJsonError } from './router/MalformedJsonError.js';
|
|
2
|
+
import { PASSTHROUGH } from './router/Next.js';
|
|
5
3
|
const METHOD_MAP = {
|
|
6
4
|
GET: 'get',
|
|
7
5
|
POST: 'post',
|
package/dist/hono.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono.js","sourceRoot":"","sources":["../src/hono.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hono.js","sourceRoot":"","sources":["../src/hono.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAc/C,MAAM,UAAU,GAAoE;IAClF,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ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,QAAQ,EAAE,cAAc,CAAC,CAAC;YACpC,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,EAAE,CAAC,MAAkB,EAAE,IAAY,EAAE,OAAgB;YACnD,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;YAC7B,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAM,EAAE,EAAE;gBAC5B,MAAM,GAAG,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;gBAC5B,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;oBAClC,OAAO,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;gBACjC,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,IAAI,GAAG,YAAY,kBAAkB;wBAAE,OAAO,qBAAqB,CAAC,CAAC,CAAC,CAAC;oBACvE,MAAM,GAAG,CAAC;gBACZ,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
export type { HttpMethod
|
|
2
|
-
export {
|
|
1
|
+
export type { HttpMethod } from './router/HttpMethod.js';
|
|
2
|
+
export type { RequestContext } from './router/RequestContext.js';
|
|
3
|
+
export type { ResponseResult } from './router/ResponseResult.js';
|
|
4
|
+
export type { Handler } from './router/Handler.js';
|
|
5
|
+
export type { Middleware } from './router/Middleware.js';
|
|
6
|
+
export type { HttpRouter } from './router/HttpRouter.js';
|
|
7
|
+
export { MalformedJsonError } from './router/MalformedJsonError.js';
|
|
8
|
+
export { type Next, PASSTHROUGH } from './router/Next.js';
|
|
3
9
|
export { createHonoRouter } from './hono.js';
|
|
4
10
|
export { createFastifyRouter } from './fastify.js';
|
|
5
11
|
export { createExpressRouter, readExpressBody } from './express.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,KAAK,IAAI,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { MalformedJsonError
|
|
1
|
+
export { MalformedJsonError } from './router/MalformedJsonError.js';
|
|
2
|
+
export { PASSTHROUGH } from './router/Next.js';
|
|
2
3
|
export { createHonoRouter } from './hono.js';
|
|
3
4
|
export { createFastifyRouter } from './fastify.js';
|
|
4
5
|
export { createExpressRouter, readExpressBody } from './express.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAa,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* HTTP request logger middleware.
|
|
3
3
|
*/
|
|
4
|
-
import type { Middleware } from './router.js';
|
|
4
|
+
import type { Middleware } from './router/Middleware.js';
|
|
5
5
|
interface LoggerLike {
|
|
6
6
|
info(msg: string, ...args: unknown[]): void;
|
|
7
7
|
warn(msg: string, ...args: unknown[]): void;
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,UAAU,UAAU;IAClB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CAC7C;AASD,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAczD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Handler.d.ts","sourceRoot":"","sources":["../../src/router/Handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Handler.js","sourceRoot":"","sources":["../../src/router/Handler.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpMethod.d.ts","sourceRoot":"","sources":["../../src/router/HttpMethod.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpMethod.js","sourceRoot":"","sources":["../../src/router/HttpMethod.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HttpMethod } from './HttpMethod.js';
|
|
2
|
+
import type { Handler } from './Handler.js';
|
|
3
|
+
import type { Middleware } from './Middleware.js';
|
|
4
|
+
import type { RequestContext } from './RequestContext.js';
|
|
5
|
+
import type { ResponseResult } from './ResponseResult.js';
|
|
6
|
+
export interface HttpRouter {
|
|
7
|
+
/** Register a global middleware. */
|
|
8
|
+
use(middleware: Middleware): void;
|
|
9
|
+
/** Register a middleware scoped to a path prefix. */
|
|
10
|
+
use(path: string, middleware: Middleware): void;
|
|
11
|
+
/** Register a route handler. */
|
|
12
|
+
on(method: HttpMethod, path: string, handler: Handler): void;
|
|
13
|
+
}
|
|
14
|
+
/** The onion chain both adapters run. */
|
|
15
|
+
export declare function chain(global: Middleware[], scoped: {
|
|
16
|
+
path: string;
|
|
17
|
+
mw: Middleware;
|
|
18
|
+
}[], ctx: RequestContext, handler: Handler): Promise<ResponseResult>;
|
|
19
|
+
//# sourceMappingURL=HttpRouter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpRouter.d.ts","sourceRoot":"","sources":["../../src/router/HttpRouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,WAAW,UAAU;IACzB,oCAAoC;IACpC,GAAG,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAClC,qDAAqD;IACrD,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAChD,gCAAgC;IAChC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9D;AAED,yCAAyC;AACzC,wBAAgB,KAAK,CACnB,MAAM,EAAE,UAAU,EAAE,EACpB,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,UAAU,CAAA;CAAE,EAAE,EAC1C,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,cAAc,CAAC,CAWzB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The onion chain both adapters run. */
|
|
2
|
+
export function chain(global, scoped, ctx, handler) {
|
|
3
|
+
const matching = [
|
|
4
|
+
...global,
|
|
5
|
+
...scoped.filter((s) => ctx.path.startsWith(s.path)).map((s) => s.mw),
|
|
6
|
+
];
|
|
7
|
+
let index = 0;
|
|
8
|
+
const next = () => index < matching.length ? matching[index++](ctx, next) : handler(ctx);
|
|
9
|
+
return next();
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=HttpRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpRouter.js","sourceRoot":"","sources":["../../src/router/HttpRouter.ts"],"names":[],"mappings":"AAeA,yCAAyC;AACzC,MAAM,UAAU,KAAK,CACnB,MAAoB,EACpB,MAA0C,EAC1C,GAAmB,EACnB,OAAgB;IAEhB,MAAM,QAAQ,GAAG;QACf,GAAG,MAAM;QACT,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACtE,CAAC;IAEF,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,IAAI,GAAG,GAA4B,EAAE,CACzC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAExE,OAAO,IAAI,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MalformedJsonError.d.ts","sourceRoot":"","sources":["../../src/router/MalformedJsonError.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAO,CAAC,EAAE,YAAY,EAGjC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Raised by an adapter when a request claims JSON but cannot be parsed. */
|
|
2
|
+
export class MalformedJsonError extends Error {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
super('Malformed JSON body', options);
|
|
5
|
+
this.name = 'MalformedJsonError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=MalformedJsonError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MalformedJsonError.js","sourceRoot":"","sources":["../../src/router/MalformedJsonError.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAsB;QAChC,KAAK,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RequestContext } from './RequestContext.js';
|
|
2
|
+
import type { ResponseResult } from './ResponseResult.js';
|
|
3
|
+
import type { Next } from './Next.js';
|
|
4
|
+
export type Middleware = (ctx: RequestContext, next: Next) => Promise<ResponseResult>;
|
|
5
|
+
//# sourceMappingURL=Middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Middleware.d.ts","sourceRoot":"","sources":["../../src/router/Middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Middleware.js","sourceRoot":"","sources":["../../src/router/Middleware.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ResponseResult } from './ResponseResult.js';
|
|
2
|
+
export type Next = () => Promise<ResponseResult>;
|
|
3
|
+
/** What `next()` answers when the host framework — not us — owns the chain. */
|
|
4
|
+
export declare const PASSTHROUGH: unique symbol;
|
|
5
|
+
//# sourceMappingURL=Next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Next.d.ts","sourceRoot":"","sources":["../../src/router/Next.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;AAEjD,+EAA+E;AAC/E,eAAO,MAAM,WAAW,EAAE,OAAO,MAA2C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Next.js","sourceRoot":"","sources":["../../src/router/Next.ts"],"names":[],"mappings":"AAIA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAkB,MAAM,CAAC,0BAA0B,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HttpMethod } from './HttpMethod.js';
|
|
2
|
+
export interface RequestContext {
|
|
3
|
+
/** The request as a Web Standard `Request`. */
|
|
4
|
+
readonly request: Request;
|
|
5
|
+
method: HttpMethod;
|
|
6
|
+
path: string;
|
|
7
|
+
params: Record<string, string>;
|
|
8
|
+
query: Record<string, string>;
|
|
9
|
+
body: () => Promise<unknown>;
|
|
10
|
+
/** Extensible bag — middlewares deposit data here (auth, session, etc.). */
|
|
11
|
+
state: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=RequestContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequestContext.d.ts","sourceRoot":"","sources":["../../src/router/RequestContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7B,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequestContext.js","sourceRoot":"","sources":["../../src/router/RequestContext.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ResponseResult {
|
|
2
|
+
status: number;
|
|
3
|
+
data: unknown;
|
|
4
|
+
headers?: Record<string, string | string[]>;
|
|
5
|
+
/** Send data as raw body (not JSON-serialized). Use for HTML, XML, CSV, plain text, etc. */
|
|
6
|
+
raw?: boolean;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ResponseResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponseResult.d.ts","sourceRoot":"","sources":["../../src/router/ResponseResult.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC5C,4FAA4F;IAC5F,GAAG,CAAC,EAAE,OAAO,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponseResult.js","sourceRoot":"","sources":["../../src/router/ResponseResult.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
package/src/express.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/** Express adapter — bridges an Express app to the HttpRouter interface. */
|
|
2
|
-
import {
|
|
2
|
+
import { type Handler } from './router/Handler.js';
|
|
3
|
+
import { type HttpMethod } from './router/HttpMethod.js';
|
|
4
|
+
import { chain, type HttpRouter } from './router/HttpRouter.js';
|
|
5
|
+
import { MalformedJsonError } from './router/MalformedJsonError.js';
|
|
6
|
+
import { type Middleware } from './router/Middleware.js';
|
|
7
|
+
import { type RequestContext } from './router/RequestContext.js';
|
|
8
|
+
import { type ResponseResult } from './router/ResponseResult.js';
|
|
3
9
|
|
|
4
10
|
interface ExpressLike {
|
|
5
11
|
use(...handlers: Function[]): void;
|
|
@@ -18,7 +24,7 @@ const METHOD_MAP: Record<HttpMethod, 'get' | 'post' | 'put' | 'patch' | 'delete'
|
|
|
18
24
|
DELETE: 'delete',
|
|
19
25
|
};
|
|
20
26
|
|
|
21
|
-
// Core declares this cap (`wire/call.ts`) and three
|
|
27
|
+
// Core declares this cap (`wire/call.ts`) and three facades read it there. This package
|
|
22
28
|
// declares NO Fougere dependency — a leaf port does not take one on the kernel for a
|
|
23
29
|
// number — so it keeps the fourth copy, deliberately.
|
|
24
30
|
const MAX_BODY_BYTES = 1024 * 1024;
|
|
@@ -53,7 +59,7 @@ export function readExpressBody(req: any): Promise<unknown> {
|
|
|
53
59
|
if (verb === 'GET' || verb === 'HEAD') return {};
|
|
54
60
|
// `null` is parsed JSON, not evidence that no parser ran. Falling through here
|
|
55
61
|
// turned an explicit domain value into `{}` (or tried to drain an already consumed
|
|
56
|
-
// stream), while every other
|
|
62
|
+
// stream), while every other facade kept it.
|
|
57
63
|
if (req.body !== undefined) return req.body;
|
|
58
64
|
const contentType = String(req.headers?.['content-type'] ?? '');
|
|
59
65
|
if (!contentType.toLowerCase().includes('json')) return {};
|
package/src/fastify.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Fastify adapter — bridges a Fastify server to the HttpRouter interface.
|
|
3
3
|
*/
|
|
4
|
-
import { chain } from './router.js';
|
|
5
|
-
import type {
|
|
4
|
+
import { chain } from './router/HttpRouter.js';
|
|
5
|
+
import type { Handler } from './router/Handler.js';
|
|
6
|
+
import type { HttpMethod } from './router/HttpMethod.js';
|
|
7
|
+
import type { HttpRouter } from './router/HttpRouter.js';
|
|
8
|
+
import type { Middleware } from './router/Middleware.js';
|
|
9
|
+
import type { RequestContext } from './router/RequestContext.js';
|
|
10
|
+
import type { ResponseResult } from './router/ResponseResult.js';
|
|
6
11
|
|
|
7
12
|
interface FastifyLike {
|
|
8
13
|
addHook(hook: string, handler: Function): void;
|
package/src/hono.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hono adapter — bridges a Hono app to the HttpRouter interface.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from './router.js';
|
|
4
|
+
import { type Handler } from './router/Handler.js';
|
|
5
|
+
import { type HttpMethod } from './router/HttpMethod.js';
|
|
6
|
+
import { type HttpRouter } from './router/HttpRouter.js';
|
|
7
|
+
import { MalformedJsonError } from './router/MalformedJsonError.js';
|
|
8
|
+
import { type Middleware } from './router/Middleware.js';
|
|
9
|
+
import { PASSTHROUGH } from './router/Next.js';
|
|
10
|
+
import { type RequestContext } from './router/RequestContext.js';
|
|
11
|
+
import { type ResponseResult } from './router/ResponseResult.js';
|
|
9
12
|
|
|
10
13
|
interface HonoLike {
|
|
11
14
|
use(path: string, ...handlers: Function[]): void;
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from './router.js';
|
|
10
|
-
export { MalformedJsonError, PASSTHROUGH } from './router.js';
|
|
1
|
+
export type { HttpMethod } from './router/HttpMethod.js';
|
|
2
|
+
export type { RequestContext } from './router/RequestContext.js';
|
|
3
|
+
export type { ResponseResult } from './router/ResponseResult.js';
|
|
4
|
+
export type { Handler } from './router/Handler.js';
|
|
5
|
+
export type { Middleware } from './router/Middleware.js';
|
|
6
|
+
export type { HttpRouter } from './router/HttpRouter.js';
|
|
7
|
+
export { MalformedJsonError } from './router/MalformedJsonError.js';
|
|
8
|
+
export { type Next, PASSTHROUGH } from './router/Next.js';
|
|
11
9
|
|
|
12
10
|
export { createHonoRouter } from './hono.js';
|
|
13
11
|
export { createFastifyRouter } from './fastify.js';
|
package/src/logger.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HttpMethod } from './HttpMethod.js';
|
|
2
|
+
import type { Handler } from './Handler.js';
|
|
3
|
+
import type { Middleware } from './Middleware.js';
|
|
4
|
+
import type { RequestContext } from './RequestContext.js';
|
|
5
|
+
import type { ResponseResult } from './ResponseResult.js';
|
|
6
|
+
|
|
7
|
+
export interface HttpRouter {
|
|
8
|
+
/** Register a global middleware. */
|
|
9
|
+
use(middleware: Middleware): void;
|
|
10
|
+
/** Register a middleware scoped to a path prefix. */
|
|
11
|
+
use(path: string, middleware: Middleware): void;
|
|
12
|
+
/** Register a route handler. */
|
|
13
|
+
on(method: HttpMethod, path: string, handler: Handler): void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The onion chain both adapters run. */
|
|
17
|
+
export function chain(
|
|
18
|
+
global: Middleware[],
|
|
19
|
+
scoped: { path: string; mw: Middleware }[],
|
|
20
|
+
ctx: RequestContext,
|
|
21
|
+
handler: Handler,
|
|
22
|
+
): Promise<ResponseResult> {
|
|
23
|
+
const matching = [
|
|
24
|
+
...global,
|
|
25
|
+
...scoped.filter((s) => ctx.path.startsWith(s.path)).map((s) => s.mw),
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
let index = 0;
|
|
29
|
+
const next = (): Promise<ResponseResult> =>
|
|
30
|
+
index < matching.length ? matching[index++](ctx, next) : handler(ctx);
|
|
31
|
+
|
|
32
|
+
return next();
|
|
33
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ResponseResult } from './ResponseResult.js';
|
|
2
|
+
|
|
3
|
+
export type Next = () => Promise<ResponseResult>;
|
|
4
|
+
|
|
5
|
+
/** What `next()` answers when the host framework — not us — owns the chain. */
|
|
6
|
+
export const PASSTHROUGH: unique symbol = Symbol('fougere.http.passthrough');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HttpMethod } from './HttpMethod.js';
|
|
2
|
+
|
|
3
|
+
export interface RequestContext {
|
|
4
|
+
/** The request as a Web Standard `Request`. */
|
|
5
|
+
readonly request: Request;
|
|
6
|
+
method: HttpMethod;
|
|
7
|
+
path: string;
|
|
8
|
+
params: Record<string, string>;
|
|
9
|
+
query: Record<string, string>;
|
|
10
|
+
body: () => Promise<unknown>;
|
|
11
|
+
/** Extensible bag — middlewares deposit data here (auth, session, etc.). */
|
|
12
|
+
state: Record<string, unknown>;
|
|
13
|
+
}
|
package/dist/router.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/** @fougere/http — framework-agnostic HTTP router interface. */
|
|
2
|
-
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
3
|
-
export interface RequestContext {
|
|
4
|
-
/** The request as a Web Standard `Request`. */
|
|
5
|
-
readonly request: Request;
|
|
6
|
-
method: HttpMethod;
|
|
7
|
-
path: string;
|
|
8
|
-
params: Record<string, string>;
|
|
9
|
-
query: Record<string, string>;
|
|
10
|
-
body: () => Promise<unknown>;
|
|
11
|
-
/** Extensible bag — middlewares deposit data here (auth, session, etc.). */
|
|
12
|
-
state: Record<string, unknown>;
|
|
13
|
-
}
|
|
14
|
-
export interface ResponseResult {
|
|
15
|
-
status: number;
|
|
16
|
-
data: unknown;
|
|
17
|
-
headers?: Record<string, string | string[]>;
|
|
18
|
-
/** Send data as raw body (not JSON-serialized). Use for HTML, XML, CSV, plain text, etc. */
|
|
19
|
-
raw?: boolean;
|
|
20
|
-
}
|
|
21
|
-
/** Raised by an adapter when a request claims JSON but cannot be parsed. */
|
|
22
|
-
export declare class MalformedJsonError extends Error {
|
|
23
|
-
constructor(options?: ErrorOptions);
|
|
24
|
-
}
|
|
25
|
-
export type Handler = (ctx: RequestContext) => Promise<ResponseResult>;
|
|
26
|
-
export type Next = () => Promise<ResponseResult>;
|
|
27
|
-
/** What `next()` answers when the host framework — not us — owns the chain. */
|
|
28
|
-
export declare const PASSTHROUGH: unique symbol;
|
|
29
|
-
export type Middleware = (ctx: RequestContext, next: Next) => Promise<ResponseResult>;
|
|
30
|
-
export interface HttpRouter {
|
|
31
|
-
/** Register a global middleware. */
|
|
32
|
-
use(middleware: Middleware): void;
|
|
33
|
-
/** Register a middleware scoped to a path prefix. */
|
|
34
|
-
use(path: string, middleware: Middleware): void;
|
|
35
|
-
/** Register a route handler. */
|
|
36
|
-
on(method: HttpMethod, path: string, handler: Handler): void;
|
|
37
|
-
}
|
|
38
|
-
/** The onion chain both adapters run. */
|
|
39
|
-
export declare function chain(global: Middleware[], scoped: {
|
|
40
|
-
path: string;
|
|
41
|
-
mw: Middleware;
|
|
42
|
-
}[], ctx: RequestContext, handler: Handler): Promise<ResponseResult>;
|
|
43
|
-
//# sourceMappingURL=router.d.ts.map
|
package/dist/router.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAEhE,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;I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MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9D;AAED,yCAAyC;AACzC,wBAAgB,KAAK,CACnB,MAAM,EAAE,UAAU,EAAE,EACpB,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,UAAU,CAAA;CAAE,EAAE,EAC1C,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,cAAc,CAAC,CAWzB"}
|
package/dist/router.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** @fougere/http — framework-agnostic HTTP router interface. */
|
|
2
|
-
/** Raised by an adapter when a request claims JSON but cannot be parsed. */
|
|
3
|
-
export class MalformedJsonError extends Error {
|
|
4
|
-
constructor(options) {
|
|
5
|
-
super('Malformed JSON body', options);
|
|
6
|
-
this.name = 'MalformedJsonError';
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
/** What `next()` answers when the host framework — not us — owns the chain. */
|
|
10
|
-
export const PASSTHROUGH = Symbol('fougere.http.passthrough');
|
|
11
|
-
/** The onion chain both adapters run. */
|
|
12
|
-
export function chain(global, scoped, ctx, handler) {
|
|
13
|
-
const matching = [
|
|
14
|
-
...global,
|
|
15
|
-
...scoped.filter((s) => ctx.path.startsWith(s.path)).map((s) => s.mw),
|
|
16
|
-
];
|
|
17
|
-
let index = 0;
|
|
18
|
-
const next = () => index < matching.length ? matching[index++](ctx, next) : handler(ctx);
|
|
19
|
-
return next();
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=router.js.map
|
package/dist/router.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAwBhE,4EAA4E;AAC5E,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAsB;QAChC,KAAK,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAID,+EAA+E;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAkB,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAa7E,yCAAyC;AACzC,MAAM,UAAU,KAAK,CACnB,MAAoB,EACpB,MAA0C,EAC1C,GAAmB,EACnB,OAAgB;IAEhB,MAAM,QAAQ,GAAG;QACf,GAAG,MAAM;QACT,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACtE,CAAC;IAEF,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,IAAI,GAAG,GAA4B,EAAE,CACzC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAExE,OAAO,IAAI,EAAE,CAAC;AAChB,CAAC"}
|
package/src/router.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/** @fougere/http — framework-agnostic HTTP router interface. */
|
|
2
|
-
|
|
3
|
-
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
4
|
-
|
|
5
|
-
export interface RequestContext {
|
|
6
|
-
/** The request as a Web Standard `Request`. */
|
|
7
|
-
readonly request: Request;
|
|
8
|
-
method: HttpMethod;
|
|
9
|
-
path: string;
|
|
10
|
-
params: Record<string, string>;
|
|
11
|
-
query: Record<string, string>;
|
|
12
|
-
body: () => Promise<unknown>;
|
|
13
|
-
/** Extensible bag — middlewares deposit data here (auth, session, etc.). */
|
|
14
|
-
state: Record<string, unknown>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ResponseResult {
|
|
18
|
-
status: number;
|
|
19
|
-
data: unknown;
|
|
20
|
-
headers?: Record<string, string | string[]>;
|
|
21
|
-
/** Send data as raw body (not JSON-serialized). Use for HTML, XML, CSV, plain text, etc. */
|
|
22
|
-
raw?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** Raised by an adapter when a request claims JSON but cannot be parsed. */
|
|
26
|
-
export class MalformedJsonError extends Error {
|
|
27
|
-
constructor(options?: ErrorOptions) {
|
|
28
|
-
super('Malformed JSON body', options);
|
|
29
|
-
this.name = 'MalformedJsonError';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type Handler = (ctx: RequestContext) => Promise<ResponseResult>;
|
|
34
|
-
export type Next = () => Promise<ResponseResult>;
|
|
35
|
-
/** What `next()` answers when the host framework — not us — owns the chain. */
|
|
36
|
-
export const PASSTHROUGH: unique symbol = Symbol('fougere.http.passthrough');
|
|
37
|
-
|
|
38
|
-
export type Middleware = (ctx: RequestContext, next: Next) => Promise<ResponseResult>;
|
|
39
|
-
|
|
40
|
-
export interface HttpRouter {
|
|
41
|
-
/** Register a global middleware. */
|
|
42
|
-
use(middleware: Middleware): void;
|
|
43
|
-
/** Register a middleware scoped to a path prefix. */
|
|
44
|
-
use(path: string, middleware: Middleware): void;
|
|
45
|
-
/** Register a route handler. */
|
|
46
|
-
on(method: HttpMethod, path: string, handler: Handler): void;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** The onion chain both adapters run. */
|
|
50
|
-
export function chain(
|
|
51
|
-
global: Middleware[],
|
|
52
|
-
scoped: { path: string; mw: Middleware }[],
|
|
53
|
-
ctx: RequestContext,
|
|
54
|
-
handler: Handler,
|
|
55
|
-
): Promise<ResponseResult> {
|
|
56
|
-
const matching = [
|
|
57
|
-
...global,
|
|
58
|
-
...scoped.filter((s) => ctx.path.startsWith(s.path)).map((s) => s.mw),
|
|
59
|
-
];
|
|
60
|
-
|
|
61
|
-
let index = 0;
|
|
62
|
-
const next = (): Promise<ResponseResult> =>
|
|
63
|
-
index < matching.length ? matching[index++](ctx, next) : handler(ctx);
|
|
64
|
-
|
|
65
|
-
return next();
|
|
66
|
-
}
|