@philiprehberger/middleware-ts 0.1.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/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 philiprehberger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @philiprehberger/middleware-ts
2
+
3
+ Framework-agnostic middleware composition engine.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @philiprehberger/middleware-ts
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { compose, createPipeline } from '@philiprehberger/middleware-ts';
15
+
16
+ type Ctx = { req: Request; user?: User };
17
+
18
+ const app = createPipeline<Ctx>()
19
+ .use(logger)
20
+ .useIf(requiresAuth, auth)
21
+ .use(handler)
22
+ .build();
23
+
24
+ await app({ req: new Request('/api') });
25
+ ```
26
+
27
+ ### Conditional Branching
28
+
29
+ ```ts
30
+ import { branch } from '@philiprehberger/middleware-ts';
31
+
32
+ const authBranch = branch(
33
+ (ctx) => ctx.req.url.startsWith('/api'),
34
+ authMiddleware,
35
+ publicMiddleware,
36
+ );
37
+ ```
38
+
39
+ ## API
40
+
41
+ | Function | Description |
42
+ |----------|-------------|
43
+ | `compose(...middlewares)` | Compose into single middleware |
44
+ | `createPipeline<Ctx>()` | Builder with `.use()` and `.useIf()` |
45
+ | `branch(condition, trueMw, falseMw?)` | Conditional middleware |
46
+ | `withErrorHandler(mw, handler)` | Wrap with error catching |
47
+
48
+ ## License
49
+
50
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ // src/compose.ts
4
+ function compose(...middlewares) {
5
+ return async (ctx, next) => {
6
+ let index = -1;
7
+ async function dispatch(i) {
8
+ if (i <= index) throw new Error("next() called multiple times");
9
+ index = i;
10
+ const mw = i < middlewares.length ? middlewares[i] : next;
11
+ if (!mw) return;
12
+ await mw(ctx, () => dispatch(i + 1));
13
+ }
14
+ await dispatch(0);
15
+ };
16
+ }
17
+
18
+ // src/pipeline.ts
19
+ function createPipeline() {
20
+ const stack = [];
21
+ const pipeline = {
22
+ use(mw) {
23
+ stack.push(mw);
24
+ return pipeline;
25
+ },
26
+ useIf(condition, mw) {
27
+ if (typeof condition === "boolean") {
28
+ if (condition) stack.push(mw);
29
+ } else {
30
+ stack.push(async (ctx, next) => {
31
+ if (condition(ctx)) {
32
+ await mw(ctx, next);
33
+ } else {
34
+ await next();
35
+ }
36
+ });
37
+ }
38
+ return pipeline;
39
+ },
40
+ build() {
41
+ const composed = compose(...stack);
42
+ return async (ctx) => {
43
+ await composed(ctx, async () => {
44
+ });
45
+ };
46
+ }
47
+ };
48
+ return pipeline;
49
+ }
50
+
51
+ // src/branch.ts
52
+ function branch(condition, trueMw, falseMw) {
53
+ return async (ctx, next) => {
54
+ if (condition(ctx)) {
55
+ await trueMw(ctx, next);
56
+ } else if (falseMw) {
57
+ await falseMw(ctx, next);
58
+ } else {
59
+ await next();
60
+ }
61
+ };
62
+ }
63
+
64
+ // src/error.ts
65
+ function withErrorHandler(mw, handler) {
66
+ return async (ctx, next) => {
67
+ try {
68
+ await mw(ctx, next);
69
+ } catch (err) {
70
+ await handler(err, ctx);
71
+ }
72
+ };
73
+ }
74
+
75
+ exports.branch = branch;
76
+ exports.compose = compose;
77
+ exports.createPipeline = createPipeline;
78
+ exports.withErrorHandler = withErrorHandler;
79
+ //# sourceMappingURL=index.cjs.map
80
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/compose.ts","../src/pipeline.ts","../src/branch.ts","../src/error.ts"],"names":[],"mappings":";;;AAEO,SAAS,WAAgB,WAAA,EAAiD;AAC/E,EAAA,OAAO,OAAO,KAAU,IAAA,KAA8B;AACpD,IAAA,IAAI,KAAA,GAAQ,EAAA;AAEZ,IAAA,eAAe,SAAS,CAAA,EAA0B;AAChD,MAAA,IAAI,CAAA,IAAK,KAAA,EAAO,MAAM,IAAI,MAAM,8BAA8B,CAAA;AAC9D,MAAA,KAAA,GAAQ,CAAA;AAER,MAAA,MAAM,KAAK,CAAA,GAAI,WAAA,CAAY,MAAA,GAAS,WAAA,CAAY,CAAC,CAAA,GAAI,IAAA;AACrD,MAAA,IAAI,CAAC,EAAA,EAAI;AAET,MAAA,MAAM,GAAG,GAAA,EAAK,MAAM,QAAA,CAAS,CAAA,GAAI,CAAC,CAAC,CAAA;AAAA,IACrC;AAEA,IAAA,MAAM,SAAS,CAAC,CAAA;AAAA,EAClB,CAAA;AACF;;;ACTO,SAAS,cAAA,GAA+C;AAC7D,EAAA,MAAM,QAA2B,EAAC;AAElC,EAAA,MAAM,QAAA,GAAoC;AAAA,IACxC,IAAI,EAAA,EAAqB;AACvB,MAAA,KAAA,CAAM,KAAK,EAAE,CAAA;AACb,MAAA,OAAO,QAAA;AAAA,IACT,CAAA;AAAA,IAEA,KAAA,CAAM,WAA8C,EAAA,EAAqB;AACvE,MAAA,IAAI,OAAO,cAAc,SAAA,EAAW;AAClC,QAAA,IAAI,SAAA,EAAW,KAAA,CAAM,IAAA,CAAK,EAAE,CAAA;AAAA,MAC9B,CAAA,MAAO;AACL,QAAA,KAAA,CAAM,IAAA,CAAK,OAAO,GAAA,EAAK,IAAA,KAAS;AAC9B,UAAA,IAAI,SAAA,CAAU,GAAG,CAAA,EAAG;AAClB,YAAA,MAAM,EAAA,CAAG,KAAK,IAAI,CAAA;AAAA,UACpB,CAAA,MAAO;AACL,YAAA,MAAM,IAAA,EAAK;AAAA,UACb;AAAA,QACF,CAAC,CAAA;AAAA,MACH;AACA,MAAA,OAAO,QAAA;AAAA,IACT,CAAA;AAAA,IAEA,KAAA,GAAQ;AACN,MAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,GAAG,KAAK,CAAA;AACjC,MAAA,OAAO,OAAO,GAAA,KAAa;AACzB,QAAA,MAAM,QAAA,CAAS,KAAK,YAAY;AAAA,QAAC,CAAC,CAAA;AAAA,MACpC,CAAA;AAAA,IACF;AAAA,GACF;AAEA,EAAA,OAAO,QAAA;AACT;;;ACxCO,SAAS,MAAA,CACd,SAAA,EACA,MAAA,EACA,OAAA,EACiB;AACjB,EAAA,OAAO,OAAO,KAAK,IAAA,KAAS;AAC1B,IAAA,IAAI,SAAA,CAAU,GAAG,CAAA,EAAG;AAClB,MAAA,MAAM,MAAA,CAAO,KAAK,IAAI,CAAA;AAAA,IACxB,WAAW,OAAA,EAAS;AAClB,MAAA,MAAM,OAAA,CAAQ,KAAK,IAAI,CAAA;AAAA,IACzB,CAAA,MAAO;AACL,MAAA,MAAM,IAAA,EAAK;AAAA,IACb;AAAA,EACF,CAAA;AACF;;;ACdO,SAAS,gBAAA,CACd,IACA,OAAA,EACiB;AACjB,EAAA,OAAO,OAAO,KAAK,IAAA,KAAS;AAC1B,IAAA,IAAI;AACF,MAAA,MAAM,EAAA,CAAG,KAAK,IAAI,CAAA;AAAA,IACpB,SAAS,GAAA,EAAK;AACZ,MAAA,MAAM,OAAA,CAAQ,KAAK,GAAG,CAAA;AAAA,IACxB;AAAA,EACF,CAAA;AACF","file":"index.cjs","sourcesContent":["import type { Middleware } from './types';\n\nexport function compose<Ctx>(...middlewares: Middleware<Ctx>[]): Middleware<Ctx> {\n return async (ctx: Ctx, next: () => Promise<void>) => {\n let index = -1;\n\n async function dispatch(i: number): Promise<void> {\n if (i <= index) throw new Error('next() called multiple times');\n index = i;\n\n const mw = i < middlewares.length ? middlewares[i] : next;\n if (!mw) return;\n\n await mw(ctx, () => dispatch(i + 1));\n }\n\n await dispatch(0);\n };\n}\n","import type { Middleware } from './types';\nimport { compose } from './compose';\n\nexport interface MiddlewarePipeline<Ctx> {\n use(mw: Middleware<Ctx>): MiddlewarePipeline<Ctx>;\n useIf(condition: boolean | ((ctx: Ctx) => boolean), mw: Middleware<Ctx>): MiddlewarePipeline<Ctx>;\n build(): (ctx: Ctx) => Promise<void>;\n}\n\nexport function createPipeline<Ctx>(): MiddlewarePipeline<Ctx> {\n const stack: Middleware<Ctx>[] = [];\n\n const pipeline: MiddlewarePipeline<Ctx> = {\n use(mw: Middleware<Ctx>) {\n stack.push(mw);\n return pipeline;\n },\n\n useIf(condition: boolean | ((ctx: Ctx) => boolean), mw: Middleware<Ctx>) {\n if (typeof condition === 'boolean') {\n if (condition) stack.push(mw);\n } else {\n stack.push(async (ctx, next) => {\n if (condition(ctx)) {\n await mw(ctx, next);\n } else {\n await next();\n }\n });\n }\n return pipeline;\n },\n\n build() {\n const composed = compose(...stack);\n return async (ctx: Ctx) => {\n await composed(ctx, async () => {});\n };\n },\n };\n\n return pipeline;\n}\n","import type { Middleware } from './types';\n\nexport function branch<Ctx>(\n condition: (ctx: Ctx) => boolean,\n trueMw: Middleware<Ctx>,\n falseMw?: Middleware<Ctx>,\n): Middleware<Ctx> {\n return async (ctx, next) => {\n if (condition(ctx)) {\n await trueMw(ctx, next);\n } else if (falseMw) {\n await falseMw(ctx, next);\n } else {\n await next();\n }\n };\n}\n","import type { Middleware, ErrorHandler } from './types';\n\nexport function withErrorHandler<Ctx>(\n mw: Middleware<Ctx>,\n handler: ErrorHandler<Ctx>,\n): Middleware<Ctx> {\n return async (ctx, next) => {\n try {\n await mw(ctx, next);\n } catch (err) {\n await handler(err, ctx);\n }\n };\n}\n"]}
@@ -0,0 +1,17 @@
1
+ type Middleware<Ctx> = (ctx: Ctx, next: () => Promise<void>) => Promise<void>;
2
+ type ErrorHandler<Ctx> = (err: unknown, ctx: Ctx) => Promise<void> | void;
3
+
4
+ declare function compose<Ctx>(...middlewares: Middleware<Ctx>[]): Middleware<Ctx>;
5
+
6
+ interface MiddlewarePipeline<Ctx> {
7
+ use(mw: Middleware<Ctx>): MiddlewarePipeline<Ctx>;
8
+ useIf(condition: boolean | ((ctx: Ctx) => boolean), mw: Middleware<Ctx>): MiddlewarePipeline<Ctx>;
9
+ build(): (ctx: Ctx) => Promise<void>;
10
+ }
11
+ declare function createPipeline<Ctx>(): MiddlewarePipeline<Ctx>;
12
+
13
+ declare function branch<Ctx>(condition: (ctx: Ctx) => boolean, trueMw: Middleware<Ctx>, falseMw?: Middleware<Ctx>): Middleware<Ctx>;
14
+
15
+ declare function withErrorHandler<Ctx>(mw: Middleware<Ctx>, handler: ErrorHandler<Ctx>): Middleware<Ctx>;
16
+
17
+ export { type ErrorHandler, type Middleware, type MiddlewarePipeline, branch, compose, createPipeline, withErrorHandler };
@@ -0,0 +1,17 @@
1
+ type Middleware<Ctx> = (ctx: Ctx, next: () => Promise<void>) => Promise<void>;
2
+ type ErrorHandler<Ctx> = (err: unknown, ctx: Ctx) => Promise<void> | void;
3
+
4
+ declare function compose<Ctx>(...middlewares: Middleware<Ctx>[]): Middleware<Ctx>;
5
+
6
+ interface MiddlewarePipeline<Ctx> {
7
+ use(mw: Middleware<Ctx>): MiddlewarePipeline<Ctx>;
8
+ useIf(condition: boolean | ((ctx: Ctx) => boolean), mw: Middleware<Ctx>): MiddlewarePipeline<Ctx>;
9
+ build(): (ctx: Ctx) => Promise<void>;
10
+ }
11
+ declare function createPipeline<Ctx>(): MiddlewarePipeline<Ctx>;
12
+
13
+ declare function branch<Ctx>(condition: (ctx: Ctx) => boolean, trueMw: Middleware<Ctx>, falseMw?: Middleware<Ctx>): Middleware<Ctx>;
14
+
15
+ declare function withErrorHandler<Ctx>(mw: Middleware<Ctx>, handler: ErrorHandler<Ctx>): Middleware<Ctx>;
16
+
17
+ export { type ErrorHandler, type Middleware, type MiddlewarePipeline, branch, compose, createPipeline, withErrorHandler };
package/dist/index.js ADDED
@@ -0,0 +1,75 @@
1
+ // src/compose.ts
2
+ function compose(...middlewares) {
3
+ return async (ctx, next) => {
4
+ let index = -1;
5
+ async function dispatch(i) {
6
+ if (i <= index) throw new Error("next() called multiple times");
7
+ index = i;
8
+ const mw = i < middlewares.length ? middlewares[i] : next;
9
+ if (!mw) return;
10
+ await mw(ctx, () => dispatch(i + 1));
11
+ }
12
+ await dispatch(0);
13
+ };
14
+ }
15
+
16
+ // src/pipeline.ts
17
+ function createPipeline() {
18
+ const stack = [];
19
+ const pipeline = {
20
+ use(mw) {
21
+ stack.push(mw);
22
+ return pipeline;
23
+ },
24
+ useIf(condition, mw) {
25
+ if (typeof condition === "boolean") {
26
+ if (condition) stack.push(mw);
27
+ } else {
28
+ stack.push(async (ctx, next) => {
29
+ if (condition(ctx)) {
30
+ await mw(ctx, next);
31
+ } else {
32
+ await next();
33
+ }
34
+ });
35
+ }
36
+ return pipeline;
37
+ },
38
+ build() {
39
+ const composed = compose(...stack);
40
+ return async (ctx) => {
41
+ await composed(ctx, async () => {
42
+ });
43
+ };
44
+ }
45
+ };
46
+ return pipeline;
47
+ }
48
+
49
+ // src/branch.ts
50
+ function branch(condition, trueMw, falseMw) {
51
+ return async (ctx, next) => {
52
+ if (condition(ctx)) {
53
+ await trueMw(ctx, next);
54
+ } else if (falseMw) {
55
+ await falseMw(ctx, next);
56
+ } else {
57
+ await next();
58
+ }
59
+ };
60
+ }
61
+
62
+ // src/error.ts
63
+ function withErrorHandler(mw, handler) {
64
+ return async (ctx, next) => {
65
+ try {
66
+ await mw(ctx, next);
67
+ } catch (err) {
68
+ await handler(err, ctx);
69
+ }
70
+ };
71
+ }
72
+
73
+ export { branch, compose, createPipeline, withErrorHandler };
74
+ //# sourceMappingURL=index.js.map
75
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/compose.ts","../src/pipeline.ts","../src/branch.ts","../src/error.ts"],"names":[],"mappings":";AAEO,SAAS,WAAgB,WAAA,EAAiD;AAC/E,EAAA,OAAO,OAAO,KAAU,IAAA,KAA8B;AACpD,IAAA,IAAI,KAAA,GAAQ,EAAA;AAEZ,IAAA,eAAe,SAAS,CAAA,EAA0B;AAChD,MAAA,IAAI,CAAA,IAAK,KAAA,EAAO,MAAM,IAAI,MAAM,8BAA8B,CAAA;AAC9D,MAAA,KAAA,GAAQ,CAAA;AAER,MAAA,MAAM,KAAK,CAAA,GAAI,WAAA,CAAY,MAAA,GAAS,WAAA,CAAY,CAAC,CAAA,GAAI,IAAA;AACrD,MAAA,IAAI,CAAC,EAAA,EAAI;AAET,MAAA,MAAM,GAAG,GAAA,EAAK,MAAM,QAAA,CAAS,CAAA,GAAI,CAAC,CAAC,CAAA;AAAA,IACrC;AAEA,IAAA,MAAM,SAAS,CAAC,CAAA;AAAA,EAClB,CAAA;AACF;;;ACTO,SAAS,cAAA,GAA+C;AAC7D,EAAA,MAAM,QAA2B,EAAC;AAElC,EAAA,MAAM,QAAA,GAAoC;AAAA,IACxC,IAAI,EAAA,EAAqB;AACvB,MAAA,KAAA,CAAM,KAAK,EAAE,CAAA;AACb,MAAA,OAAO,QAAA;AAAA,IACT,CAAA;AAAA,IAEA,KAAA,CAAM,WAA8C,EAAA,EAAqB;AACvE,MAAA,IAAI,OAAO,cAAc,SAAA,EAAW;AAClC,QAAA,IAAI,SAAA,EAAW,KAAA,CAAM,IAAA,CAAK,EAAE,CAAA;AAAA,MAC9B,CAAA,MAAO;AACL,QAAA,KAAA,CAAM,IAAA,CAAK,OAAO,GAAA,EAAK,IAAA,KAAS;AAC9B,UAAA,IAAI,SAAA,CAAU,GAAG,CAAA,EAAG;AAClB,YAAA,MAAM,EAAA,CAAG,KAAK,IAAI,CAAA;AAAA,UACpB,CAAA,MAAO;AACL,YAAA,MAAM,IAAA,EAAK;AAAA,UACb;AAAA,QACF,CAAC,CAAA;AAAA,MACH;AACA,MAAA,OAAO,QAAA;AAAA,IACT,CAAA;AAAA,IAEA,KAAA,GAAQ;AACN,MAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,GAAG,KAAK,CAAA;AACjC,MAAA,OAAO,OAAO,GAAA,KAAa;AACzB,QAAA,MAAM,QAAA,CAAS,KAAK,YAAY;AAAA,QAAC,CAAC,CAAA;AAAA,MACpC,CAAA;AAAA,IACF;AAAA,GACF;AAEA,EAAA,OAAO,QAAA;AACT;;;ACxCO,SAAS,MAAA,CACd,SAAA,EACA,MAAA,EACA,OAAA,EACiB;AACjB,EAAA,OAAO,OAAO,KAAK,IAAA,KAAS;AAC1B,IAAA,IAAI,SAAA,CAAU,GAAG,CAAA,EAAG;AAClB,MAAA,MAAM,MAAA,CAAO,KAAK,IAAI,CAAA;AAAA,IACxB,WAAW,OAAA,EAAS;AAClB,MAAA,MAAM,OAAA,CAAQ,KAAK,IAAI,CAAA;AAAA,IACzB,CAAA,MAAO;AACL,MAAA,MAAM,IAAA,EAAK;AAAA,IACb;AAAA,EACF,CAAA;AACF;;;ACdO,SAAS,gBAAA,CACd,IACA,OAAA,EACiB;AACjB,EAAA,OAAO,OAAO,KAAK,IAAA,KAAS;AAC1B,IAAA,IAAI;AACF,MAAA,MAAM,EAAA,CAAG,KAAK,IAAI,CAAA;AAAA,IACpB,SAAS,GAAA,EAAK;AACZ,MAAA,MAAM,OAAA,CAAQ,KAAK,GAAG,CAAA;AAAA,IACxB;AAAA,EACF,CAAA;AACF","file":"index.js","sourcesContent":["import type { Middleware } from './types';\n\nexport function compose<Ctx>(...middlewares: Middleware<Ctx>[]): Middleware<Ctx> {\n return async (ctx: Ctx, next: () => Promise<void>) => {\n let index = -1;\n\n async function dispatch(i: number): Promise<void> {\n if (i <= index) throw new Error('next() called multiple times');\n index = i;\n\n const mw = i < middlewares.length ? middlewares[i] : next;\n if (!mw) return;\n\n await mw(ctx, () => dispatch(i + 1));\n }\n\n await dispatch(0);\n };\n}\n","import type { Middleware } from './types';\nimport { compose } from './compose';\n\nexport interface MiddlewarePipeline<Ctx> {\n use(mw: Middleware<Ctx>): MiddlewarePipeline<Ctx>;\n useIf(condition: boolean | ((ctx: Ctx) => boolean), mw: Middleware<Ctx>): MiddlewarePipeline<Ctx>;\n build(): (ctx: Ctx) => Promise<void>;\n}\n\nexport function createPipeline<Ctx>(): MiddlewarePipeline<Ctx> {\n const stack: Middleware<Ctx>[] = [];\n\n const pipeline: MiddlewarePipeline<Ctx> = {\n use(mw: Middleware<Ctx>) {\n stack.push(mw);\n return pipeline;\n },\n\n useIf(condition: boolean | ((ctx: Ctx) => boolean), mw: Middleware<Ctx>) {\n if (typeof condition === 'boolean') {\n if (condition) stack.push(mw);\n } else {\n stack.push(async (ctx, next) => {\n if (condition(ctx)) {\n await mw(ctx, next);\n } else {\n await next();\n }\n });\n }\n return pipeline;\n },\n\n build() {\n const composed = compose(...stack);\n return async (ctx: Ctx) => {\n await composed(ctx, async () => {});\n };\n },\n };\n\n return pipeline;\n}\n","import type { Middleware } from './types';\n\nexport function branch<Ctx>(\n condition: (ctx: Ctx) => boolean,\n trueMw: Middleware<Ctx>,\n falseMw?: Middleware<Ctx>,\n): Middleware<Ctx> {\n return async (ctx, next) => {\n if (condition(ctx)) {\n await trueMw(ctx, next);\n } else if (falseMw) {\n await falseMw(ctx, next);\n } else {\n await next();\n }\n };\n}\n","import type { Middleware, ErrorHandler } from './types';\n\nexport function withErrorHandler<Ctx>(\n mw: Middleware<Ctx>,\n handler: ErrorHandler<Ctx>,\n): Middleware<Ctx> {\n return async (ctx, next) => {\n try {\n await mw(ctx, next);\n } catch (err) {\n await handler(err, ctx);\n }\n };\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@philiprehberger/middleware-ts",
3
+ "version": "0.1.0",
4
+ "description": "Framework-agnostic middleware composition engine",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": { ".": { "import": { "types": "./dist/index.d.ts", "default": "./dist/index.js" }, "require": { "types": "./dist/index.d.cts", "default": "./dist/index.cjs" } } },
10
+ "files": ["dist"],
11
+ "scripts": { "build": "tsup", "dev": "tsup --watch", "typecheck": "tsc --noEmit", "prepublishOnly": "npm run build" },
12
+ "devDependencies": { "tsup": "^8.0.0", "typescript": "^5.0.0" },
13
+ "keywords": ["middleware", "compose", "pipeline", "chain", "handler", "context"],
14
+ "license": "MIT",
15
+ "repository": { "type": "git", "url": "git+https://github.com/philiprehberger/ts-middleware-ts.git" },
16
+ "homepage": "https://github.com/philiprehberger/ts-middleware-ts#readme",
17
+ "bugs": { "url": "https://github.com/philiprehberger/ts-middleware-ts/issues" },
18
+ "author": "Philip Rehberger",
19
+ "engines": { "node": ">=18.0.0" },
20
+ "sideEffects": false
21
+ }