@taserjs/router 0.0.4 → 0.0.5

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.
Files changed (153) hide show
  1. package/dist/cjs/builder/app.cjs +22 -0
  2. package/dist/cjs/builder/app.cjs.map +1 -0
  3. package/dist/cjs/builder/app.d.cts +11 -0
  4. package/dist/cjs/{constants.cjs → builder/constants.cjs} +1 -1
  5. package/dist/cjs/builder/constants.cjs.map +1 -0
  6. package/dist/cjs/{factories.cjs → builder/factories.cjs} +1 -1
  7. package/dist/cjs/builder/factories.cjs.map +1 -0
  8. package/dist/cjs/{factories.d.cts → builder/factories.d.cts} +2 -2
  9. package/dist/cjs/{middleware.cjs → builder/middleware.cjs} +1 -1
  10. package/dist/cjs/builder/middleware.cjs.map +1 -0
  11. package/dist/cjs/{middleware.d.cts → builder/middleware.d.cts} +1 -1
  12. package/dist/cjs/{route.cjs → builder/route.cjs} +19 -33
  13. package/dist/cjs/builder/route.cjs.map +1 -0
  14. package/dist/cjs/{route.d.cts → builder/route.d.cts} +3 -3
  15. package/dist/cjs/{taser-router.cjs → builder/router.cjs} +38 -11
  16. package/dist/cjs/builder/router.cjs.map +1 -0
  17. package/dist/cjs/builder/router.d.cts +48 -0
  18. package/dist/cjs/{create-context.cjs → context/create-context.cjs} +1 -1
  19. package/dist/cjs/context/create-context.cjs.map +1 -0
  20. package/dist/cjs/{create-context.d.cts → context/create-context.d.cts} +2 -2
  21. package/dist/cjs/define/validators.cjs +1 -1
  22. package/dist/cjs/define/validators.cjs.map +1 -1
  23. package/dist/cjs/define/validators.d.cts +1 -1
  24. package/dist/cjs/index.cjs +6 -16
  25. package/dist/cjs/index.d.cts +6 -7
  26. package/dist/cjs/middleware/body-limit.cjs +2 -2
  27. package/dist/cjs/middleware/body-limit.cjs.map +1 -1
  28. package/dist/cjs/middleware/compress.cjs +2 -2
  29. package/dist/cjs/middleware/compress.cjs.map +1 -1
  30. package/dist/cjs/middleware/cors.cjs +2 -2
  31. package/dist/cjs/middleware/cors.cjs.map +1 -1
  32. package/dist/cjs/middleware/csrf.cjs +2 -2
  33. package/dist/cjs/middleware/csrf.cjs.map +1 -1
  34. package/dist/cjs/middleware/etag.cjs +2 -2
  35. package/dist/cjs/middleware/etag.cjs.map +1 -1
  36. package/dist/cjs/middleware/jwk.cjs +2 -8
  37. package/dist/cjs/middleware/jwk.cjs.map +1 -1
  38. package/dist/cjs/middleware/jwt.cjs +2 -8
  39. package/dist/cjs/middleware/jwt.cjs.map +1 -1
  40. package/dist/cjs/middleware/secure-headers.cjs +2 -2
  41. package/dist/cjs/middleware/secure-headers.cjs.map +1 -1
  42. package/dist/cjs/middleware/timing.cjs +2 -2
  43. package/dist/cjs/middleware/timing.cjs.map +1 -1
  44. package/dist/cjs/middleware/wrap-hono.cjs +10 -0
  45. package/dist/cjs/middleware/wrap-hono.cjs.map +1 -1
  46. package/dist/cjs/middleware/wrap-hono.d.cts +4 -0
  47. package/dist/cjs/types/app.d.cts +7 -7
  48. package/dist/cjs/types/index.d.cts +32 -13
  49. package/dist/cjs/types/returns.d.cts +2 -2
  50. package/dist/cjs/types/type-utils.d.cts +1 -2
  51. package/dist/cjs/types/units.cjs.map +1 -1
  52. package/dist/cjs/types/units.d.cts +4 -9
  53. package/dist/esm/builder/app.d.ts +11 -0
  54. package/dist/esm/builder/app.js +22 -0
  55. package/dist/esm/builder/app.js.map +1 -0
  56. package/dist/esm/{constants.js → builder/constants.js} +1 -1
  57. package/dist/esm/builder/constants.js.map +1 -0
  58. package/dist/esm/{factories.d.ts → builder/factories.d.ts} +2 -2
  59. package/dist/esm/{factories.js → builder/factories.js} +1 -1
  60. package/dist/esm/builder/factories.js.map +1 -0
  61. package/dist/esm/{middleware.d.ts → builder/middleware.d.ts} +1 -1
  62. package/dist/esm/{middleware.js → builder/middleware.js} +1 -1
  63. package/dist/esm/builder/middleware.js.map +1 -0
  64. package/dist/esm/{route.d.ts → builder/route.d.ts} +3 -3
  65. package/dist/esm/{route.js → builder/route.js} +19 -33
  66. package/dist/esm/builder/route.js.map +1 -0
  67. package/dist/esm/builder/router.d.ts +48 -0
  68. package/dist/esm/{taser-router.js → builder/router.js} +37 -10
  69. package/dist/esm/builder/router.js.map +1 -0
  70. package/dist/esm/{create-context.d.ts → context/create-context.d.ts} +2 -2
  71. package/dist/esm/{create-context.js → context/create-context.js} +1 -1
  72. package/dist/esm/context/create-context.js.map +1 -0
  73. package/dist/esm/define/validators.d.ts +1 -1
  74. package/dist/esm/define/validators.js +1 -1
  75. package/dist/esm/define/validators.js.map +1 -1
  76. package/dist/esm/index.d.ts +6 -7
  77. package/dist/esm/index.js +5 -6
  78. package/dist/esm/middleware/body-limit.js +2 -2
  79. package/dist/esm/middleware/body-limit.js.map +1 -1
  80. package/dist/esm/middleware/compress.js +2 -2
  81. package/dist/esm/middleware/compress.js.map +1 -1
  82. package/dist/esm/middleware/cors.js +2 -2
  83. package/dist/esm/middleware/cors.js.map +1 -1
  84. package/dist/esm/middleware/csrf.js +2 -2
  85. package/dist/esm/middleware/csrf.js.map +1 -1
  86. package/dist/esm/middleware/etag.js +2 -2
  87. package/dist/esm/middleware/etag.js.map +1 -1
  88. package/dist/esm/middleware/jwk.js +2 -8
  89. package/dist/esm/middleware/jwk.js.map +1 -1
  90. package/dist/esm/middleware/jwt.js +2 -8
  91. package/dist/esm/middleware/jwt.js.map +1 -1
  92. package/dist/esm/middleware/secure-headers.js +2 -2
  93. package/dist/esm/middleware/secure-headers.js.map +1 -1
  94. package/dist/esm/middleware/timing.js +2 -2
  95. package/dist/esm/middleware/timing.js.map +1 -1
  96. package/dist/esm/middleware/wrap-hono.d.ts +4 -0
  97. package/dist/esm/middleware/wrap-hono.js +10 -1
  98. package/dist/esm/middleware/wrap-hono.js.map +1 -1
  99. package/dist/esm/types/app.d.ts +7 -7
  100. package/dist/esm/types/index.d.ts +32 -13
  101. package/dist/esm/types/returns.d.ts +2 -2
  102. package/dist/esm/types/type-utils.d.ts +1 -2
  103. package/dist/esm/types/units.d.ts +4 -9
  104. package/dist/esm/types/units.js.map +1 -1
  105. package/package.json +3 -3
  106. package/src/builder/app.ts +28 -0
  107. package/src/{factories.ts → builder/factories.ts} +2 -2
  108. package/src/{middleware.ts → builder/middleware.ts} +2 -2
  109. package/src/{route.ts → builder/route.ts} +30 -34
  110. package/src/builder/router.ts +347 -0
  111. package/src/{create-context.ts → context/create-context.ts} +2 -2
  112. package/src/define/validators.ts +1 -1
  113. package/src/index.ts +9 -12
  114. package/src/middleware/body-limit.ts +2 -2
  115. package/src/middleware/compress.ts +2 -2
  116. package/src/middleware/cors.ts +2 -2
  117. package/src/middleware/csrf.ts +2 -2
  118. package/src/middleware/etag.ts +2 -2
  119. package/src/middleware/jwk.ts +2 -7
  120. package/src/middleware/jwt.ts +2 -7
  121. package/src/middleware/secure-headers.ts +2 -2
  122. package/src/middleware/timing.ts +2 -2
  123. package/src/middleware/wrap-hono.ts +13 -0
  124. package/src/types/app.ts +12 -8
  125. package/src/types/index.ts +44 -10
  126. package/src/types/returns.ts +2 -2
  127. package/src/types/type-utils.ts +1 -2
  128. package/src/types/units.ts +4 -8
  129. package/dist/cjs/constants.cjs.map +0 -1
  130. package/dist/cjs/create-context.cjs.map +0 -1
  131. package/dist/cjs/factories.cjs.map +0 -1
  132. package/dist/cjs/middleware.cjs.map +0 -1
  133. package/dist/cjs/route.cjs.map +0 -1
  134. package/dist/cjs/taser-app.cjs +0 -36
  135. package/dist/cjs/taser-app.cjs.map +0 -1
  136. package/dist/cjs/taser-app.d.cts +0 -18
  137. package/dist/cjs/taser-router.cjs.map +0 -1
  138. package/dist/cjs/taser-router.d.cts +0 -42
  139. package/dist/esm/constants.js.map +0 -1
  140. package/dist/esm/create-context.js.map +0 -1
  141. package/dist/esm/factories.js.map +0 -1
  142. package/dist/esm/middleware.js.map +0 -1
  143. package/dist/esm/route.js.map +0 -1
  144. package/dist/esm/taser-app.d.ts +0 -18
  145. package/dist/esm/taser-app.js +0 -35
  146. package/dist/esm/taser-app.js.map +0 -1
  147. package/dist/esm/taser-router.d.ts +0 -42
  148. package/dist/esm/taser-router.js.map +0 -1
  149. package/src/taser-app.ts +0 -38
  150. package/src/taser-router.ts +0 -165
  151. /package/dist/cjs/{constants.d.cts → builder/constants.d.cts} +0 -0
  152. /package/dist/esm/{constants.d.ts → builder/constants.d.ts} +0 -0
  153. /package/src/{constants.ts → builder/constants.ts} +0 -0
@@ -21,7 +21,6 @@ import type {
21
21
  MiddlewareDefinition,
22
22
  MiddlewareReturnFromParts,
23
23
  MiddlewareUnit,
24
- NativeContext,
25
24
  ValidatorParts,
26
25
  } from "./units.js";
27
26
 
@@ -48,7 +47,7 @@ export type {
48
47
  HandlerReply,
49
48
  HasReturns,
50
49
  MergeReturns,
51
- ReplyResultFor,
50
+ ReplyFor,
52
51
  ReturnsMap,
53
52
  StatusCode,
54
53
  ValidHandlerReply,
@@ -66,7 +65,6 @@ export type {
66
65
  MiddlewareNext,
67
66
  MiddlewareReturnFromParts,
68
67
  MiddlewareUnit,
69
- NativeContext,
70
68
  NextFn,
71
69
  NextResult,
72
70
  StandaloneMiddlewareContext,
@@ -97,6 +95,13 @@ export type PathParams<Path extends string> = Path extends `/${infer Rest}`
97
95
  ? ParseParamsFromSegments<Rest>
98
96
  : {};
99
97
 
98
+ export type ResolveParams<TPathParams, TSchemaParams> =
99
+ TSchemaParams extends Record<string, unknown>
100
+ ? [keyof TSchemaParams] extends [never]
101
+ ? TPathParams
102
+ : Simplify<Omit<TPathParams, keyof TSchemaParams> & TSchemaParams>
103
+ : TPathParams;
104
+
100
105
  type LayoutParent<Layout extends LayoutId> = LayoutTree[Layout] extends {
101
106
  parent: infer Parent extends LayoutId | null;
102
107
  }
@@ -177,7 +182,7 @@ type RouteChainField<
177
182
  Field extends "query" | "params" | "body" | "state",
178
183
  > = RouteResolvedField<Path, TMethod, Acc, Field>;
179
184
 
180
- type UnitRuntimeContext = Omit<RuntimeContextFields<NativeContext>, "var">;
185
+ type UnitRuntimeContext = Omit<RuntimeContextFields, "var">;
181
186
 
182
187
  export type RouteChainContext<
183
188
  Path extends RoutePath,
@@ -192,7 +197,10 @@ export type RouteChainContext<
192
197
  UnitRuntimeContext & {
193
198
  query: Simplify<MergePart<TQuery, RouteChainField<Path, TMethod, Acc, "query">>>;
194
199
  params: Simplify<
195
- PathParams<Path> & MergePart<TParams, RouteChainField<Path, TMethod, Acc, "params">>
200
+ ResolveParams<
201
+ PathParams<Path>,
202
+ MergePart<TParams, RouteChainField<Path, TMethod, Acc, "params">>
203
+ >
196
204
  >;
197
205
  body: Simplify<MergePart<TBody, RouteChainField<Path, TMethod, Acc, "body">>>;
198
206
  state: Simplify<RouteChainField<Path, TMethod, Acc, "state">>;
@@ -223,11 +231,13 @@ export type RouteHandleContext<
223
231
  >
224
232
  >;
225
233
  params: Simplify<
226
- PathParams<Path> &
234
+ ResolveParams<
235
+ PathParams<Path>,
227
236
  MergePart<
228
237
  Validators extends { params?: infer P } ? P : unknown,
229
238
  RouteResolvedField<Path, TMethod, Acc, "params">
230
239
  >
240
+ >
231
241
  >;
232
242
  body: Simplify<
233
243
  MergePart<
@@ -262,11 +272,13 @@ export type RouteHandleContextWithoutBody<
262
272
  >
263
273
  >;
264
274
  params: Simplify<
265
- PathParams<Path> &
275
+ ResolveParams<
276
+ PathParams<Path>,
266
277
  MergePart<
267
278
  Validators extends { params?: infer P } ? P : unknown,
268
279
  RouteResolvedField<Path, TMethod, Acc, "params">
269
280
  >
281
+ >
270
282
  >;
271
283
  body: never;
272
284
  state: Simplify<RouteResolvedField<Path, TMethod, Acc, "state">>;
@@ -348,7 +360,8 @@ type RouteParamsInput<
348
360
  Acc extends readonly unknown[],
349
361
  Validators extends ValidatorParts,
350
362
  > = Simplify<
351
- PathParams<Path> &
363
+ ResolveParams<
364
+ PathParams<Path>,
352
365
  MergePart<
353
366
  RequestShape<
354
367
  Validators extends { paramsIn?: infer PI } ? PI : unknown,
@@ -356,6 +369,7 @@ type RouteParamsInput<
356
369
  >,
357
370
  RouteResolvedInputField<Path, TMethod, Acc, "params">
358
371
  >
372
+ >
359
373
  >;
360
374
 
361
375
  type RouteBodyInput<
@@ -393,7 +407,7 @@ export type RouteHandleInput<
393
407
  InputFacet<RouteBodyInput<Path, TMethod, Acc, Validators>, "body">
394
408
  >;
395
409
 
396
- export type InferRouteInput<Path extends RoutePath, TMethod extends Method> =
410
+ export type InferRouteInputFromPath<Path extends RoutePath, TMethod extends Method> =
397
411
  RouteEntry<Path, TMethod> extends { route: infer Route }
398
412
  ? Route extends { $Infer: { Input: infer I } }
399
413
  ? I
@@ -510,7 +524,9 @@ export type RouteExport<
510
524
  Context: TMethod extends "GET" | "DELETE" | "HEAD" | "OPTIONS"
511
525
  ? RouteHandleContextWithoutBody<Path, TMethod, Acc, {}>
512
526
  : RouteHandleContext<Path, TMethod, Acc, {}>;
513
- /** Concrete handler reply (`ReplyOf` union) for client inference. */
527
+ Input: TMethod extends "GET" | "DELETE" | "HEAD" | "OPTIONS"
528
+ ? RouteHandleInputWithoutBody<Path, TMethod, Acc, {}>
529
+ : RouteHandleInput<Path, TMethod, Acc, {}>;
514
530
  Output: TOutput;
515
531
  };
516
532
  query?: Schema<unknown>;
@@ -555,6 +571,10 @@ export type RouteBuilder<
555
571
  Context: TMethod extends "GET" | "DELETE" | "HEAD" | "OPTIONS"
556
572
  ? RouteHandleContextWithoutBody<Path, TMethod, Acc, Validators, TAppContext>
557
573
  : RouteHandleContext<Path, TMethod, Acc, Validators, TAppContext>;
574
+ Input: TMethod extends "GET" | "DELETE" | "HEAD" | "OPTIONS"
575
+ ? RouteHandleInputWithoutBody<Path, TMethod, Acc, Validators>
576
+ : RouteHandleInput<Path, TMethod, Acc, Validators>;
577
+ Output: TReturns;
558
578
  };
559
579
  returns<const M extends ReturnsMap>(
560
580
  map: M,
@@ -734,3 +754,17 @@ export type HandlerBuilder<
734
754
  ]
735
755
  ): HandlerUnit<Acc, Validators, TReturns, R>;
736
756
  };
757
+
758
+ export type RouteDefinition<
759
+ Path extends RoutePath = RoutePath,
760
+ TMethod extends Method = Method,
761
+ Acc extends readonly unknown[] = readonly unknown[],
762
+ Validators extends ValidatorParts = ValidatorParts,
763
+ TReturns extends ReturnsMap = ReturnsMap,
764
+ TOutput = Response,
765
+ TAppContext extends Record<string, unknown> = AppContext,
766
+ > = RouteHandleResult<Path, TMethod, Acc, Validators, TReturns, TOutput, TAppContext>;
767
+
768
+ export type InferRouteContext<R> = R extends { $Infer: { Context: infer C } } ? C : never;
769
+ export type InferRouteInput<R> = R extends { $Infer: { Input: infer I } } ? I : never;
770
+ export type InferRouteOutput<R> = R extends { $Infer: { Output: infer O } } ? O : never;
@@ -83,7 +83,7 @@ export type ReturnsMap = {
83
83
  export type MergeReturns<A extends ReturnsMap, B extends ReturnsMap> = Omit<A, keyof B> & B;
84
84
 
85
85
  /** Typed reply union for statuses declared in a returns map. */
86
- export type ReplyResultFor<M extends ReturnsMap> = {
86
+ export type ReplyFor<M extends ReturnsMap> = {
87
87
  [S in keyof M]-?: S extends StatusCode
88
88
  ? M[S] extends Schema<unknown>
89
89
  ? ReplyOf<S, Simplify<InferOutput<M[S]>>>
@@ -127,4 +127,4 @@ export type EnforceHandlerReply<R, M extends ReturnsMap> = [R] extends [ValidHan
127
127
  * Prefer constraining handler generics with {@link EnforceHandlerReply}.
128
128
  */
129
129
  export type HandlerReply<M extends ReturnsMap> =
130
- HasReturns<M> extends true ? ReplyResultFor<M> | Response : Response;
130
+ HasReturns<M> extends true ? ReplyFor<M> | Response : Response;
@@ -71,12 +71,11 @@ export type MergeMiddlewareInputField<
71
71
  ? {}
72
72
  : UnionToIntersection<MiddlewareInputField<Middlewares[number], Field>>;
73
73
 
74
- export type RuntimeContextFields<TNative = unknown> = {
74
+ export type RuntimeContextFields = {
75
75
  request: Request;
76
76
  method: Method;
77
77
  url: URL;
78
78
  headers: import("@taserjs/router-core").TaserHeaders;
79
79
  cookies: import("@taserjs/router-core").TaserCookieJar;
80
80
  var: Record<string, unknown>;
81
- native?: TNative;
82
81
  };
@@ -1,7 +1,5 @@
1
1
  import type { Awaitable, TaserCookieJar, TaserHeaders } from "@taserjs/router-core";
2
- import type { ReplyResult } from "@taserjs/router-utils";
3
2
 
4
- import type { RouterRegister } from "../register.js";
5
3
  import type {
6
4
  MergeMiddlewareField,
7
5
  MergePart,
@@ -28,8 +26,6 @@ export type {
28
26
  /** Default empty app context for standalone units without a bound router instance. */
29
27
  export type AppContext = Record<never, never>;
30
28
 
31
- export type NativeContext = RouterRegister extends { NativeContext: infer N } ? N : unknown;
32
-
33
29
  export type ValidatorParts = {
34
30
  query?: unknown;
35
31
  params?: unknown;
@@ -41,7 +37,7 @@ export type ValidatorParts = {
41
37
 
42
38
  export declare const StateBrand: unique symbol;
43
39
 
44
- export type NextResult<TState = unknown> = ReplyResult & {
40
+ export type NextResult<TState = unknown> = Response & {
45
41
  readonly [StateBrand]?: TState;
46
42
  };
47
43
 
@@ -67,7 +63,7 @@ export type MiddlewareDefinition = {
67
63
  params?: unknown;
68
64
  body?: unknown;
69
65
  returns?: ReturnsMap;
70
- handler: (ctx: unknown, next: MiddlewareNext) => Awaitable<ReplyResult | Response | unknown>;
66
+ handler: (ctx: unknown, next: MiddlewareNext) => Awaitable<Response | unknown>;
71
67
  };
72
68
 
73
69
  export type MiddlewareReturnFromParts<
@@ -91,7 +87,7 @@ export type MiddlewareReturnFromParts<
91
87
  };
92
88
  };
93
89
 
94
- type UnitRuntimeContext = Omit<RuntimeContextFields<NativeContext>, "var">;
90
+ type UnitRuntimeContext = Omit<RuntimeContextFields, "var">;
95
91
 
96
92
  export type StandaloneMiddlewareContext<
97
93
  TQuery = unknown,
@@ -165,7 +161,7 @@ export type HandlerUnit<
165
161
  Output: TOutput;
166
162
  };
167
163
  middlewares: readonly MiddlewareDefinition[];
168
- handler: (ctx: unknown) => Awaitable<ReplyResult | Response>;
164
+ handler: (ctx: unknown) => Awaitable<Response>;
169
165
  returns?: ReturnsMap;
170
166
  query?: Schema<unknown>;
171
167
  params?: Schema<unknown>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.cjs","names":[],"sources":["../../src/constants.ts"],"sourcesContent":["/** Input schema keys validated by middleware and route handlers. Headers/cookies are parsed only. */\nexport const SCHEMA_KEYS = [\"query\", \"params\", \"body\"] as const;\n\nexport type SchemaKey = (typeof SCHEMA_KEYS)[number];\n\nexport const HANDLER_SCHEMA_KEY_MAP = {\n query: \"handlerQuery\",\n params: \"handlerParams\",\n body: \"handlerBody\",\n} as const satisfies Record<SchemaKey, string>;\n"],"mappings":";;AACA,IAAa,cAAc;CAAC;CAAS;CAAU;AAAM;AAIrD,IAAa,yBAAyB;CACpC,OAAO;CACP,QAAQ;CACR,MAAM;AACR"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-context.cjs","names":[],"sources":["../../src/create-context.ts"],"sourcesContent":["import type { ReservedContextKey } from \"@taserjs/router-core\";\n\nimport type { ContextDefinition } from \"./types/app.js\";\n\ntype NoReservedKeysConstraint<\n TBoot extends Record<string, unknown>,\n TReq extends Record<string, unknown>,\n> = Extract<keyof TBoot | keyof TReq, ReservedContextKey> extends never ? unknown : never;\n\nexport function createContext<\n TBoot extends Record<string, unknown> = Record<string, never>,\n TReq extends Record<string, unknown> = Record<string, never>,\n>(\n definition: ContextDefinition<TBoot, TReq> & NoReservedKeysConstraint<TBoot, TReq>,\n): ContextDefinition<TBoot, TReq> {\n return definition;\n}\n\nexport type { ContextDefinition, InferAppContext } from \"./types/app.js\";\n"],"mappings":";AASA,SAAgB,cAId,YACgC;CAChC,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"factories.cjs","names":[],"sources":["../../src/factories.ts"],"sourcesContent":["import { createRouteBuilder } from \"./route.js\";\nimport type { RouteBuilder, RoutePath, Schema } from \"./types/index.js\";\nimport type { AppContext, HttpMethod } from \"./types/units.js\";\n\ntype WithoutBodyOptions<TQuery, TParams, TQueryIn = unknown, TParamsIn = unknown> = {\n query?: Schema<TQuery, TQueryIn>;\n params?: Schema<TParams, TParamsIn>;\n};\n\ntype WithBodyOptions<\n TQuery,\n TParams,\n TBody,\n TQueryIn = unknown,\n TParamsIn = unknown,\n TBodyIn = unknown,\n> = WithoutBodyOptions<TQuery, TParams, TQueryIn, TParamsIn> & {\n body?: Schema<TBody, TBodyIn>;\n};\n\nexport type CreateWithoutBodyRoute<\n M extends \"GET\" | \"DELETE\" | \"OPTIONS\" | \"HEAD\",\n TAppContext extends Record<string, unknown> = AppContext,\n> = {\n <const Path extends RoutePath>(\n path: Path,\n ): RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;\n <\n const Path extends RoutePath,\n TQuery = unknown,\n TParams = unknown,\n TQueryIn = unknown,\n TParamsIn = unknown,\n >(\n path: Path,\n options: WithoutBodyOptions<TQuery, TParams, TQueryIn, TParamsIn>,\n ): RouteBuilder<\n Path,\n M,\n readonly [],\n {\n query: TQuery;\n params: TParams;\n queryIn: TQueryIn;\n paramsIn: TParamsIn;\n },\n {},\n TAppContext\n >;\n};\n\nexport type CreateWithBodyRoute<\n M extends \"POST\" | \"PUT\" | \"PATCH\",\n TAppContext extends Record<string, unknown> = AppContext,\n> = {\n <const Path extends RoutePath>(\n path: Path,\n ): RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;\n <\n const Path extends RoutePath,\n TQuery = unknown,\n TParams = unknown,\n TBody = unknown,\n TQueryIn = unknown,\n TParamsIn = unknown,\n TBodyIn = unknown,\n >(\n path: Path,\n options: WithBodyOptions<TQuery, TParams, TBody, TQueryIn, TParamsIn, TBodyIn>,\n ): RouteBuilder<\n Path,\n M,\n readonly [],\n {\n query: TQuery;\n params: TParams;\n body: TBody;\n queryIn: TQueryIn;\n paramsIn: TParamsIn;\n bodyIn: TBodyIn;\n },\n {},\n TAppContext\n >;\n};\n\nexport type CreateAnyRoute<TAppContext extends Record<string, unknown> = AppContext> = {\n <const Path extends RoutePath, const Methods extends readonly HttpMethod[]>(\n path: Path,\n methods: Methods,\n ): RouteBuilder<Path, Methods[number], readonly [], {}, {}, TAppContext>;\n <\n const Path extends RoutePath,\n const Methods extends readonly HttpMethod[],\n TQuery = unknown,\n TParams = unknown,\n TBody = unknown,\n TQueryIn = unknown,\n TParamsIn = unknown,\n TBodyIn = unknown,\n >(\n path: Path,\n methods: Methods,\n options: WithBodyOptions<TQuery, TParams, TBody, TQueryIn, TParamsIn, TBodyIn>,\n ): RouteBuilder<\n Path,\n Methods[number],\n readonly [],\n {\n query: TQuery;\n params: TParams;\n body: TBody;\n queryIn: TQueryIn;\n paramsIn: TParamsIn;\n bodyIn: TBodyIn;\n },\n {},\n TAppContext\n >;\n};\n\nexport type CreateAllRoute<TAppContext extends Record<string, unknown> = AppContext> = {\n <const Path extends RoutePath>(\n path: Path,\n ): RouteBuilder<Path, HttpMethod, readonly [], {}, {}, TAppContext>;\n <\n const Path extends RoutePath,\n TQuery = unknown,\n TParams = unknown,\n TBody = unknown,\n TQueryIn = unknown,\n TParamsIn = unknown,\n TBodyIn = unknown,\n >(\n path: Path,\n options: WithBodyOptions<TQuery, TParams, TBody, TQueryIn, TParamsIn, TBodyIn>,\n ): RouteBuilder<\n Path,\n HttpMethod,\n readonly [],\n {\n query: TQuery;\n params: TParams;\n body: TBody;\n queryIn: TQueryIn;\n paramsIn: TParamsIn;\n bodyIn: TBodyIn;\n },\n {},\n TAppContext\n >;\n};\n\nfunction createWithoutBodyRoute<M extends \"GET\" | \"DELETE\" | \"OPTIONS\" | \"HEAD\">(\n method: M,\n): CreateWithoutBodyRoute<M> {\n return ((path: string, options?: WithoutBodyOptions<unknown, unknown>) =>\n createRouteBuilder(path, method, options)) as unknown as CreateWithoutBodyRoute<M>;\n}\n\nfunction createWithBodyRoute<M extends \"POST\" | \"PUT\" | \"PATCH\">(\n method: M,\n): CreateWithBodyRoute<M> {\n return ((path: string, options?: WithBodyOptions<unknown, unknown, unknown>) =>\n createRouteBuilder(path, method, options)) as unknown as CreateWithBodyRoute<M>;\n}\n\nexport const createGetRoute = createWithoutBodyRoute(\"GET\");\nexport const createDeleteRoute = createWithoutBodyRoute(\"DELETE\");\nexport const createOptionsRoute = createWithoutBodyRoute(\"OPTIONS\");\nexport const createHeadRoute = createWithoutBodyRoute(\"HEAD\");\nexport const createPostRoute = createWithBodyRoute(\"POST\");\nexport const createPutRoute = createWithBodyRoute(\"PUT\");\nexport const createPatchRoute = createWithBodyRoute(\"PATCH\");\n\nexport const createAnyRoute: CreateAnyRoute = ((\n path: string,\n methods: readonly HttpMethod[],\n options?: WithBodyOptions<unknown, unknown, unknown>,\n) => createRouteBuilder(path, \"ANY\", options, methods)) as unknown as CreateAnyRoute;\n\nexport const createAllRoute: CreateAllRoute = ((\n path: string,\n options?: WithBodyOptions<unknown, unknown, unknown>,\n) => createRouteBuilder(path, \"ALL\", options)) as unknown as CreateAllRoute;\n"],"mappings":";;AAyJA,SAAS,uBACP,QAC2B;CAC3B,SAAS,MAAc,YACrB,cAAA,mBAAmB,MAAM,QAAQ,OAAO;AAC5C;AAEA,SAAS,oBACP,QACwB;CACxB,SAAS,MAAc,YACrB,cAAA,mBAAmB,MAAM,QAAQ,OAAO;AAC5C;AAEA,IAAa,iBAAiB,uBAAuB,KAAK;AAC1D,IAAa,oBAAoB,uBAAuB,QAAQ;AAChE,IAAa,qBAAqB,uBAAuB,SAAS;AAClE,IAAa,kBAAkB,uBAAuB,MAAM;AAC5D,IAAa,kBAAkB,oBAAoB,MAAM;AACzD,IAAa,iBAAiB,oBAAoB,KAAK;AACvD,IAAa,mBAAmB,oBAAoB,OAAO;AAE3D,IAAa,mBACX,MACA,SACA,YACG,cAAA,mBAAmB,MAAM,OAAO,SAAS,OAAO;AAErD,IAAa,mBACX,MACA,YACG,cAAA,mBAAmB,MAAM,OAAO,OAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"middleware.cjs","names":[],"sources":["../../src/middleware.ts"],"sourcesContent":["import type { LayoutId, MiddlewareBuilder } from \"./types/index.js\";\nimport type { MiddlewareDefinition } from \"./types/units.js\";\n\nexport function createMiddleware<const Layout extends LayoutId>(\n layout: Layout,\n): MiddlewareBuilder<Layout, readonly []> {\n const entries: MiddlewareDefinition[] = [];\n\n const chain = {\n layout,\n middlewares: entries,\n use(definition: MiddlewareDefinition) {\n entries.push(definition);\n return chain;\n },\n };\n\n return chain as unknown as MiddlewareBuilder<Layout, readonly []>;\n}\n"],"mappings":";AAGA,SAAgB,iBACd,QACwC;CACxC,MAAM,UAAkC,CAAC;CAEzC,MAAM,QAAQ;EACZ;EACA,aAAa;EACb,IAAI,YAAkC;GACpC,QAAQ,KAAK,UAAU;GACvB,OAAO;EACT;CACF;CAEA,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"route.cjs","names":[],"sources":["../../src/route.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport {\n collectReturnsFromDefinitions,\n hasInputSchemas,\n mergeReturnsMaps,\n withAuto422,\n} from \"@taserjs/router-utils\";\n\nimport type { Method, RouteBuilder, RoutePath, ReturnsMap, ValidatorParts } from \"./types/index.js\";\nimport type { HttpMethod, MiddlewareDefinition } from \"./types/units.js\";\nimport { isHandlerUnit } from \"./types/units.js\";\nimport { HANDLER_SCHEMA_KEY_MAP } from \"./constants.js\";\nimport { pickDefinedSchemas, type SchemaValidators } from \"./define/validators.js\";\n\nfunction toUtilsMap(map: ReturnsMap | undefined): Record<number, StandardSchemaV1> {\n if (!map) {\n return {};\n }\n const out: Record<number, StandardSchemaV1> = {};\n for (const [key, schema] of Object.entries(map)) {\n if (schema !== undefined) {\n out[Number(key)] = schema;\n }\n }\n return out;\n}\n\nfunction buildEffectiveReturns(args: {\n middlewareReturns: ReturnsMap;\n routeReturns: ReturnsMap;\n handlerMiddlewareReturns: ReturnsMap;\n handlerReturns: ReturnsMap | undefined;\n schemas: {\n query?: unknown;\n params?: unknown;\n body?: unknown;\n handlerQuery?: unknown;\n handlerParams?: unknown;\n handlerBody?: unknown;\n middlewares?: readonly MiddlewareDefinition[];\n handlerMiddlewares?: readonly MiddlewareDefinition[];\n };\n}): Record<number, StandardSchemaV1> | undefined {\n const merged = mergeReturnsMaps(\n toUtilsMap(args.middlewareReturns),\n toUtilsMap(args.routeReturns),\n toUtilsMap(args.handlerMiddlewareReturns),\n toUtilsMap(args.handlerReturns),\n );\n const with422 = withAuto422(merged, hasInputSchemas(args.schemas));\n return Object.keys(with422).length > 0 ? with422 : undefined;\n}\n\nfunction buildRouteBase(\n path: string,\n method: HttpMethod | \"ANY\" | \"ALL\",\n methods: readonly HttpMethod[] | undefined,\n middlewares: MiddlewareDefinition[],\n) {\n return {\n path,\n method,\n ...(methods ? { methods: [...methods] } : {}),\n middlewares: [...middlewares],\n };\n}\n\n/** Shared internal builder — not part of the public `@taserjs/router` API. */\nexport function createRouteBuilder(\n path: string,\n method: HttpMethod | \"ANY\" | \"ALL\",\n validators: SchemaValidators = {},\n methods?: readonly HttpMethod[],\n): RouteBuilder<RoutePath, Method, readonly [], ValidatorParts> {\n const middlewares: MiddlewareDefinition[] = [];\n let routeReturns: Record<number, StandardSchemaV1> = {};\n\n const builder = {\n path,\n method,\n returns(map: ReturnsMap) {\n routeReturns = { ...routeReturns, ...toUtilsMap(map) };\n return builder;\n },\n use(definition: MiddlewareDefinition) {\n middlewares.push(definition);\n return builder;\n },\n handler(fnOrUnit: ((ctx: unknown) => unknown) | unknown) {\n const routeSchemas = pickDefinedSchemas(validators);\n const base = buildRouteBase(path, method, methods, middlewares);\n\n if (isHandlerUnit(fnOrUnit)) {\n const handlerSchemas = pickDefinedSchemas(fnOrUnit, HANDLER_SCHEMA_KEY_MAP);\n const returns = buildEffectiveReturns({\n middlewareReturns: collectReturnsFromDefinitions(middlewares),\n routeReturns: routeReturns,\n handlerMiddlewareReturns: collectReturnsFromDefinitions(fnOrUnit.middlewares),\n handlerReturns: fnOrUnit.returns,\n schemas: {\n ...validators,\n handlerQuery: fnOrUnit.query,\n handlerParams: fnOrUnit.params,\n handlerBody: fnOrUnit.body,\n middlewares,\n handlerMiddlewares: fnOrUnit.middlewares,\n },\n });\n\n return {\n ...base,\n handlerMiddlewares: [...fnOrUnit.middlewares],\n handler: fnOrUnit.handler,\n ...routeSchemas,\n ...handlerSchemas,\n ...(returns ? { returns } : {}),\n };\n }\n\n const returns = buildEffectiveReturns({\n middlewareReturns: collectReturnsFromDefinitions(middlewares),\n routeReturns: routeReturns,\n handlerMiddlewareReturns: {},\n handlerReturns: undefined,\n schemas: {\n ...validators,\n middlewares,\n },\n });\n\n return {\n ...base,\n handlerMiddlewares: [],\n handler: fnOrUnit as (ctx: unknown) => Response | Promise<Response>,\n ...routeSchemas,\n ...(returns ? { returns } : {}),\n };\n },\n };\n\n return builder as unknown as RouteBuilder<RoutePath, Method, readonly [], ValidatorParts>;\n}\n"],"mappings":";;;;;AAcA,SAAS,WAAW,KAA+D;CACjF,IAAI,CAAC,KACH,OAAO,CAAC;CAEV,MAAM,MAAwC,CAAC;CAC/C,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,GAAG,GAC5C,IAAI,WAAW,KAAA,GACb,IAAI,OAAO,GAAG,KAAK;CAGvB,OAAO;AACT;AAEA,SAAS,sBAAsB,MAekB;CAO/C,MAAM,WAAA,GAAA,sBAAA,YAAA,EAAA,GAAA,sBAAA,iBAAA,CALJ,WAAW,KAAK,iBAAiB,GACjC,WAAW,KAAK,YAAY,GAC5B,WAAW,KAAK,wBAAwB,GACxC,WAAW,KAAK,cAAc,CAEJ,IAAA,GAAA,sBAAA,gBAAA,CAAwB,KAAK,OAAO,CAAC;CACjE,OAAO,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,IAAI,UAAU,KAAA;AACrD;AAEA,SAAS,eACP,MACA,QACA,SACA,aACA;CACA,OAAO;EACL;EACA;EACA,GAAI,UAAU,EAAE,SAAS,CAAC,GAAG,OAAO,EAAE,IAAI,CAAC;EAC3C,aAAa,CAAC,GAAG,WAAW;CAC9B;AACF;;AAGA,SAAgB,mBACd,MACA,QACA,aAA+B,CAAC,GAChC,SAC8D;CAC9D,MAAM,cAAsC,CAAC;CAC7C,IAAI,eAAiD,CAAC;CAEtD,MAAM,UAAU;EACd;EACA;EACA,QAAQ,KAAiB;GACvB,eAAe;IAAE,GAAG;IAAc,GAAG,WAAW,GAAG;GAAE;GACrD,OAAO;EACT;EACA,IAAI,YAAkC;GACpC,YAAY,KAAK,UAAU;GAC3B,OAAO;EACT;EACA,QAAQ,UAAiD;GACvD,MAAM,eAAe,mBAAA,mBAAmB,UAAU;GAClD,MAAM,OAAO,eAAe,MAAM,QAAQ,SAAS,WAAW;GAE9D,IAAI,cAAA,cAAc,QAAQ,GAAG;IAC3B,MAAM,iBAAiB,mBAAA,mBAAmB,UAAU,kBAAA,sBAAsB;IAC1E,MAAM,UAAU,sBAAsB;KACpC,oBAAA,GAAA,sBAAA,8BAAA,CAAiD,WAAW;KAC9C;KACd,2BAAA,GAAA,sBAAA,8BAAA,CAAwD,SAAS,WAAW;KAC5E,gBAAgB,SAAS;KACzB,SAAS;MACP,GAAG;MACH,cAAc,SAAS;MACvB,eAAe,SAAS;MACxB,aAAa,SAAS;MACtB;MACA,oBAAoB,SAAS;KAC/B;IACF,CAAC;IAED,OAAO;KACL,GAAG;KACH,oBAAoB,CAAC,GAAG,SAAS,WAAW;KAC5C,SAAS,SAAS;KAClB,GAAG;KACH,GAAG;KACH,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;IAC/B;GACF;GAEA,MAAM,UAAU,sBAAsB;IACpC,oBAAA,GAAA,sBAAA,8BAAA,CAAiD,WAAW;IAC9C;IACd,0BAA0B,CAAC;IAC3B,gBAAgB,KAAA;IAChB,SAAS;KACP,GAAG;KACH;IACF;GACF,CAAC;GAED,OAAO;IACL,GAAG;IACH,oBAAoB,CAAC;IACrB,SAAS;IACT,GAAG;IACH,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;GAC/B;EACF;CACF;CAEA,OAAO;AACT"}
@@ -1,36 +0,0 @@
1
- //#region src/taser-app.ts
2
- var TaserServeView = class {
3
- runtime;
4
- constructor(runtime) {
5
- this.runtime = runtime;
6
- }
7
- fetch(request, env, executionCtx) {
8
- return this.runtime.fetch(request, env, executionCtx);
9
- }
10
- native(native) {
11
- return new TaserNativeBound(this.runtime, native);
12
- }
13
- };
14
- var TaserNativeBound = class {
15
- runtime;
16
- boundNative;
17
- constructor(runtime, boundNative) {
18
- this.runtime = runtime;
19
- this.boundNative = boundNative;
20
- }
21
- fetch(request, env, executionCtx) {
22
- return this.runtime.native(this.boundNative).fetch(request, env, executionCtx);
23
- }
24
- };
25
- var TaserApp = class extends TaserServeView {
26
- __manifest;
27
- constructor(runtime, manifest) {
28
- super(runtime);
29
- if (manifest !== void 0) this.__manifest = manifest;
30
- }
31
- };
32
- //#endregion
33
- exports.TaserApp = TaserApp;
34
- exports.TaserNativeBound = TaserNativeBound;
35
-
36
- //# sourceMappingURL=taser-app.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"taser-app.cjs","names":[],"sources":["../../src/taser-app.ts"],"sourcesContent":["import type { TaserRuntime } from \"@taserjs/router-core\";\nimport type { RouteManifestShape } from \"@taserjs/router-core\";\n\nclass TaserServeView {\n constructor(protected readonly runtime: TaserRuntime) {}\n\n fetch(request: Request, env?: unknown, executionCtx?: unknown): Promise<Response> {\n return this.runtime.fetch(request, env, executionCtx as never);\n }\n\n native(native: unknown): TaserNativeBound {\n return new TaserNativeBound(this.runtime, native);\n }\n}\n\nexport class TaserNativeBound {\n constructor(\n private readonly runtime: TaserRuntime,\n private readonly boundNative: unknown,\n ) {}\n\n fetch(request: Request, env?: unknown, executionCtx?: unknown): Promise<Response> {\n return this.runtime.native(this.boundNative).fetch(request, env, executionCtx as never);\n }\n}\n\nexport class TaserApp<\n TManifest extends RouteManifestShape = RouteManifestShape,\n> extends TaserServeView {\n readonly __manifest?: TManifest;\n\n constructor(runtime: TaserRuntime, manifest?: TManifest) {\n super(runtime);\n if (manifest !== undefined) {\n this.__manifest = manifest;\n }\n }\n}\n"],"mappings":";AAGA,IAAM,iBAAN,MAAqB;CACY;CAA/B,YAAY,SAA0C;EAAvB,KAAA,UAAA;CAAwB;CAEvD,MAAM,SAAkB,KAAe,cAA2C;EAChF,OAAO,KAAK,QAAQ,MAAM,SAAS,KAAK,YAAqB;CAC/D;CAEA,OAAO,QAAmC;EACxC,OAAO,IAAI,iBAAiB,KAAK,SAAS,MAAM;CAClD;AACF;AAEA,IAAa,mBAAb,MAA8B;CAET;CACA;CAFnB,YACE,SACA,aACA;EAFiB,KAAA,UAAA;EACA,KAAA,cAAA;CAChB;CAEH,MAAM,SAAkB,KAAe,cAA2C;EAChF,OAAO,KAAK,QAAQ,OAAO,KAAK,WAAW,CAAC,CAAC,MAAM,SAAS,KAAK,YAAqB;CACxF;AACF;AAEA,IAAa,WAAb,cAEU,eAAe;CACvB;CAEA,YAAY,SAAuB,UAAsB;EACvD,MAAM,OAAO;EACb,IAAI,aAAa,KAAA,GACf,KAAK,aAAa;CAEtB;AACF"}
@@ -1,18 +0,0 @@
1
- import { TaserRuntime, RouteManifestShape } from '@taserjs/router-core';
2
- declare class TaserServeView {
3
- protected readonly runtime: TaserRuntime;
4
- constructor(runtime: TaserRuntime);
5
- fetch(request: Request, env?: unknown, executionCtx?: unknown): Promise<Response>;
6
- native(native: unknown): TaserNativeBound;
7
- }
8
- export declare class TaserNativeBound {
9
- private readonly runtime;
10
- private readonly boundNative;
11
- constructor(runtime: TaserRuntime, boundNative: unknown);
12
- fetch(request: Request, env?: unknown, executionCtx?: unknown): Promise<Response>;
13
- }
14
- export declare class TaserApp<TManifest extends RouteManifestShape = RouteManifestShape> extends TaserServeView {
15
- readonly __manifest?: TManifest;
16
- constructor(runtime: TaserRuntime, manifest?: TManifest);
17
- }
18
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"taser-router.cjs","names":[],"sources":["../../src/taser-router.ts"],"sourcesContent":["import {\n createTaserRuntime,\n type NotFoundHandler,\n type OnErrorHandler,\n type RouteManifestShape,\n} from \"@taserjs/router-core\";\nimport { normalizeOnError } from \"@taserjs/router-utils\";\n\nimport {\n createAllRoute,\n createAnyRoute,\n createDeleteRoute,\n createGetRoute,\n createHeadRoute,\n createOptionsRoute,\n createPatchRoute,\n createPostRoute,\n createPutRoute,\n} from \"./factories.js\";\nimport { defineHandler } from \"./define/handler.js\";\nimport { createMiddleware } from \"./middleware.js\";\nimport { TaserApp } from \"./taser-app.js\";\nimport type { ContextDefinition, CreateTaserAppOptions, OnErrorOptions } from \"./types/app.js\";\nimport type { AppContext } from \"./types/units.js\";\nimport type { HandlerBuilder, LayoutId, MiddlewareBuilder } from \"./types/index.js\";\nimport type { Schema } from \"./types/schema.js\";\nimport type {\n CreateAllRoute,\n CreateAnyRoute,\n CreateWithBodyRoute,\n CreateWithoutBodyRoute,\n} from \"./factories.js\";\n\nfunction toOnErrorHandler(\n onErrorOptions: OnErrorOptions | OnErrorOptions[\"handle\"],\n): OnErrorHandler {\n return normalizeOnError(onErrorOptions);\n}\n\ntype RouterState = {\n options: CreateTaserAppOptions;\n contextDef: ContextDefinition<Record<string, unknown>, Record<string, unknown>>;\n onError?: OnErrorHandler;\n notFound?: NotFoundHandler;\n};\n\nconst emptyContext: ContextDefinition<Record<string, unknown>, Record<string, unknown>> = {};\n\nexport class TaserRouter<TAppContext extends Record<string, unknown> = AppContext> {\n private readonly state: RouterState;\n\n constructor(options: CreateTaserAppOptions = {}, state?: Partial<Omit<RouterState, \"options\">>) {\n this.state = {\n options,\n contextDef: state?.contextDef ?? emptyContext,\n ...(state?.onError !== undefined ? { onError: state.onError } : {}),\n ...(state?.notFound !== undefined ? { notFound: state.notFound } : {}),\n };\n }\n\n context<TBoot extends Record<string, unknown>, TReq extends Record<string, unknown>>(\n definition: ContextDefinition<TBoot, TReq>,\n ): TaserRouter<TBoot & TReq> {\n this.state.contextDef = definition;\n return this as unknown as TaserRouter<TBoot & TReq>;\n }\n\n onError<\n TResponses extends import(\"./types/returns.js\").ReturnsMap =\n import(\"./types/returns.js\").ReturnsMap,\n >(options: OnErrorOptions<TResponses> | OnErrorOptions<TResponses>[\"handle\"]): this {\n this.state.onError = toOnErrorHandler(options);\n return this;\n }\n\n notFound(handler: (ctx: unknown) => Response | Promise<Response> | unknown): this {\n this.state.notFound = (ctx) => handler(ctx);\n return this;\n }\n\n get: CreateWithoutBodyRoute<\"GET\", TAppContext> = createGetRoute as CreateWithoutBodyRoute<\n \"GET\",\n TAppContext\n >;\n post: CreateWithBodyRoute<\"POST\", TAppContext> = createPostRoute as CreateWithBodyRoute<\n \"POST\",\n TAppContext\n >;\n put: CreateWithBodyRoute<\"PUT\", TAppContext> = createPutRoute as CreateWithBodyRoute<\n \"PUT\",\n TAppContext\n >;\n patch: CreateWithBodyRoute<\"PATCH\", TAppContext> = createPatchRoute as CreateWithBodyRoute<\n \"PATCH\",\n TAppContext\n >;\n delete: CreateWithoutBodyRoute<\"DELETE\", TAppContext> =\n createDeleteRoute as CreateWithoutBodyRoute<\"DELETE\", TAppContext>;\n options: CreateWithoutBodyRoute<\"OPTIONS\", TAppContext> =\n createOptionsRoute as CreateWithoutBodyRoute<\"OPTIONS\", TAppContext>;\n head: CreateWithoutBodyRoute<\"HEAD\", TAppContext> = createHeadRoute as CreateWithoutBodyRoute<\n \"HEAD\",\n TAppContext\n >;\n any: CreateAnyRoute<TAppContext> = createAnyRoute as CreateAnyRoute<TAppContext>;\n all: CreateAllRoute<TAppContext> = createAllRoute as CreateAllRoute<TAppContext>;\n\n middleware<const Layout extends LayoutId>(\n layout: Layout,\n ): MiddlewareBuilder<Layout, readonly [], TAppContext> {\n return createMiddleware(layout) as MiddlewareBuilder<Layout, readonly [], TAppContext>;\n }\n\n defineHandler<TQuery = unknown, TParams = unknown, TBody = unknown>(options?: {\n query?: Schema<TQuery>;\n params?: Schema<TParams>;\n body?: Schema<TBody>;\n }): HandlerBuilder<\n readonly [],\n { query: TQuery; params: TParams; body: TBody },\n {},\n TAppContext\n > {\n return options === undefined\n ? defineHandler<TAppContext>()\n : defineHandler<TAppContext>(options);\n }\n\n create<const TManifest extends RouteManifestShape>(manifest: TManifest): TaserApp<TManifest> {\n const definition = this.state.contextDef;\n const validateResponse = this.state.options.response?.validate ?? true;\n const onValidationFailure = this.state.options.response?.onValidationFailure;\n const basePath = this.state.options.basePath;\n\n const hasCustomContext = definition.boot !== undefined || definition.request !== undefined;\n const bootPromise = hasCustomContext\n ? Promise.resolve(definition.boot?.() ?? ({} as Record<string, unknown>))\n : undefined;\n\n const contextFactory = hasCustomContext\n ? async ({ native }: { native?: unknown } = {}) => {\n const bootContext = (await bootPromise) ?? {};\n const requestContext = (await definition.request?.({ native: native as never })) ?? {};\n return { ...bootContext, ...requestContext };\n }\n : () => ({});\n\n const runtime = createTaserRuntime(manifest, contextFactory, {\n ...(basePath !== undefined ? { basePath } : {}),\n response: {\n validate: validateResponse,\n ...(onValidationFailure !== undefined ? { onValidationFailure } : {}),\n },\n ...(this.state.onError !== undefined ? { onError: this.state.onError } : {}),\n ...(this.state.notFound !== undefined ? { notFound: this.state.notFound } : {}),\n ...(this.state.options.cookies !== undefined ? { cookies: this.state.options.cookies } : {}),\n });\n\n return new TaserApp(runtime, manifest);\n }\n}\n\nexport function createTaserApp(options: CreateTaserAppOptions = {}): TaserRouter {\n return new TaserRouter(options);\n}\n"],"mappings":";;;;;;;AAiCA,SAAS,iBACP,gBACgB;CAChB,QAAA,GAAA,sBAAA,iBAAA,CAAwB,cAAc;AACxC;AASA,IAAM,eAAoF,CAAC;AAE3F,IAAa,cAAb,MAAmF;CACjF;CAEA,YAAY,UAAiC,CAAC,GAAG,OAA+C;EAC9F,KAAK,QAAQ;GACX;GACA,YAAY,OAAO,cAAc;GACjC,GAAI,OAAO,YAAY,KAAA,IAAY,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;GACjE,GAAI,OAAO,aAAa,KAAA,IAAY,EAAE,UAAU,MAAM,SAAS,IAAI,CAAC;EACtE;CACF;CAEA,QACE,YAC2B;EAC3B,KAAK,MAAM,aAAa;EACxB,OAAO;CACT;CAEA,QAGE,SAAkF;EAClF,KAAK,MAAM,UAAU,iBAAiB,OAAO;EAC7C,OAAO;CACT;CAEA,SAAS,SAAyE;EAChF,KAAK,MAAM,YAAY,QAAQ,QAAQ,GAAG;EAC1C,OAAO;CACT;CAEA,MAAkD,kBAAA;CAIlD,OAAiD,kBAAA;CAIjD,MAA+C,kBAAA;CAI/C,QAAmD,kBAAA;CAInD,SACE,kBAAA;CACF,UACE,kBAAA;CACF,OAAoD,kBAAA;CAIpD,MAAmC,kBAAA;CACnC,MAAmC,kBAAA;CAEnC,WACE,QACqD;EACrD,OAAO,mBAAA,iBAAiB,MAAM;CAChC;CAEA,cAAoE,SASlE;EACA,OAAO,YAAY,KAAA,IACf,gBAAA,cAA2B,IAC3B,gBAAA,cAA2B,OAAO;CACxC;CAEA,OAAmD,UAA0C;EAC3F,MAAM,aAAa,KAAK,MAAM;EAC9B,MAAM,mBAAmB,KAAK,MAAM,QAAQ,UAAU,YAAY;EAClE,MAAM,sBAAsB,KAAK,MAAM,QAAQ,UAAU;EACzD,MAAM,WAAW,KAAK,MAAM,QAAQ;EAEpC,MAAM,mBAAmB,WAAW,SAAS,KAAA,KAAa,WAAW,YAAY,KAAA;EACjF,MAAM,cAAc,mBAChB,QAAQ,QAAQ,WAAW,OAAO,KAAM,CAAC,CAA6B,IACtE,KAAA;EAqBJ,OAAO,IAAI,kBAAA,UAAA,GAAA,qBAAA,mBAAA,CAXwB,UARZ,mBACnB,OAAO,EAAE,WAAiC,CAAC,MAAM;GAC/C,MAAM,cAAe,MAAM,eAAgB,CAAC;GAC5C,MAAM,iBAAkB,MAAM,WAAW,UAAU,EAAU,OAAgB,CAAC,KAAM,CAAC;GACrF,OAAO;IAAE,GAAG;IAAa,GAAG;GAAe;EAC7C,WACO,CAAC,IAEiD;GAC3D,GAAI,aAAa,KAAA,IAAY,EAAE,SAAS,IAAI,CAAC;GAC7C,UAAU;IACR,UAAU;IACV,GAAI,wBAAwB,KAAA,IAAY,EAAE,oBAAoB,IAAI,CAAC;GACrE;GACA,GAAI,KAAK,MAAM,YAAY,KAAA,IAAY,EAAE,SAAS,KAAK,MAAM,QAAQ,IAAI,CAAC;GAC1E,GAAI,KAAK,MAAM,aAAa,KAAA,IAAY,EAAE,UAAU,KAAK,MAAM,SAAS,IAAI,CAAC;GAC7E,GAAI,KAAK,MAAM,QAAQ,YAAY,KAAA,IAAY,EAAE,SAAS,KAAK,MAAM,QAAQ,QAAQ,IAAI,CAAC;EAC5F,CAEoB,GAAS,QAAQ;CACvC;AACF;AAEA,SAAgB,eAAe,UAAiC,CAAC,GAAgB;CAC/E,OAAO,IAAI,YAAY,OAAO;AAChC"}
@@ -1,42 +0,0 @@
1
- import { NotFoundHandler, OnErrorHandler, RouteManifestShape } from '@taserjs/router-core';
2
- import { TaserApp } from './taser-app.js';
3
- import { ContextDefinition, CreateTaserAppOptions, OnErrorOptions } from './types/app.js';
4
- import { AppContext } from './types/units.js';
5
- import { HandlerBuilder, LayoutId, MiddlewareBuilder } from './types/index.js';
6
- import { Schema } from './types/schema.js';
7
- import { CreateAllRoute, CreateAnyRoute, CreateWithBodyRoute, CreateWithoutBodyRoute } from './factories.js';
8
- type RouterState = {
9
- options: CreateTaserAppOptions;
10
- contextDef: ContextDefinition<Record<string, unknown>, Record<string, unknown>>;
11
- onError?: OnErrorHandler;
12
- notFound?: NotFoundHandler;
13
- };
14
- export declare class TaserRouter<TAppContext extends Record<string, unknown> = AppContext> {
15
- private readonly state;
16
- constructor(options?: CreateTaserAppOptions, state?: Partial<Omit<RouterState, "options">>);
17
- context<TBoot extends Record<string, unknown>, TReq extends Record<string, unknown>>(definition: ContextDefinition<TBoot, TReq>): TaserRouter<TBoot & TReq>;
18
- onError<TResponses extends import('./types/returns.js').ReturnsMap = import('./types/returns.js').ReturnsMap>(options: OnErrorOptions<TResponses> | OnErrorOptions<TResponses>["handle"]): this;
19
- notFound(handler: (ctx: unknown) => Response | Promise<Response> | unknown): this;
20
- get: CreateWithoutBodyRoute<"GET", TAppContext>;
21
- post: CreateWithBodyRoute<"POST", TAppContext>;
22
- put: CreateWithBodyRoute<"PUT", TAppContext>;
23
- patch: CreateWithBodyRoute<"PATCH", TAppContext>;
24
- delete: CreateWithoutBodyRoute<"DELETE", TAppContext>;
25
- options: CreateWithoutBodyRoute<"OPTIONS", TAppContext>;
26
- head: CreateWithoutBodyRoute<"HEAD", TAppContext>;
27
- any: CreateAnyRoute<TAppContext>;
28
- all: CreateAllRoute<TAppContext>;
29
- middleware<const Layout extends LayoutId>(layout: Layout): MiddlewareBuilder<Layout, readonly [], TAppContext>;
30
- defineHandler<TQuery = unknown, TParams = unknown, TBody = unknown>(options?: {
31
- query?: Schema<TQuery>;
32
- params?: Schema<TParams>;
33
- body?: Schema<TBody>;
34
- }): HandlerBuilder<readonly [], {
35
- query: TQuery;
36
- params: TParams;
37
- body: TBody;
38
- }, {}, TAppContext>;
39
- create<const TManifest extends RouteManifestShape>(manifest: TManifest): TaserApp<TManifest>;
40
- }
41
- export declare function createTaserApp(options?: CreateTaserAppOptions): TaserRouter;
42
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","names":[],"sources":["../../src/constants.ts"],"sourcesContent":["/** Input schema keys validated by middleware and route handlers. Headers/cookies are parsed only. */\nexport const SCHEMA_KEYS = [\"query\", \"params\", \"body\"] as const;\n\nexport type SchemaKey = (typeof SCHEMA_KEYS)[number];\n\nexport const HANDLER_SCHEMA_KEY_MAP = {\n query: \"handlerQuery\",\n params: \"handlerParams\",\n body: \"handlerBody\",\n} as const satisfies Record<SchemaKey, string>;\n"],"mappings":";;AACA,IAAa,cAAc;CAAC;CAAS;CAAU;AAAM;AAIrD,IAAa,yBAAyB;CACpC,OAAO;CACP,QAAQ;CACR,MAAM;AACR"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-context.js","names":[],"sources":["../../src/create-context.ts"],"sourcesContent":["import type { ReservedContextKey } from \"@taserjs/router-core\";\n\nimport type { ContextDefinition } from \"./types/app.js\";\n\ntype NoReservedKeysConstraint<\n TBoot extends Record<string, unknown>,\n TReq extends Record<string, unknown>,\n> = Extract<keyof TBoot | keyof TReq, ReservedContextKey> extends never ? unknown : never;\n\nexport function createContext<\n TBoot extends Record<string, unknown> = Record<string, never>,\n TReq extends Record<string, unknown> = Record<string, never>,\n>(\n definition: ContextDefinition<TBoot, TReq> & NoReservedKeysConstraint<TBoot, TReq>,\n): ContextDefinition<TBoot, TReq> {\n return definition;\n}\n\nexport type { ContextDefinition, InferAppContext } from \"./types/app.js\";\n"],"mappings":";AASA,SAAgB,cAId,YACgC;CAChC,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"factories.js","names":[],"sources":["../../src/factories.ts"],"sourcesContent":["import { createRouteBuilder } from \"./route.js\";\nimport type { RouteBuilder, RoutePath, Schema } from \"./types/index.js\";\nimport type { AppContext, HttpMethod } from \"./types/units.js\";\n\ntype WithoutBodyOptions<TQuery, TParams, TQueryIn = unknown, TParamsIn = unknown> = {\n query?: Schema<TQuery, TQueryIn>;\n params?: Schema<TParams, TParamsIn>;\n};\n\ntype WithBodyOptions<\n TQuery,\n TParams,\n TBody,\n TQueryIn = unknown,\n TParamsIn = unknown,\n TBodyIn = unknown,\n> = WithoutBodyOptions<TQuery, TParams, TQueryIn, TParamsIn> & {\n body?: Schema<TBody, TBodyIn>;\n};\n\nexport type CreateWithoutBodyRoute<\n M extends \"GET\" | \"DELETE\" | \"OPTIONS\" | \"HEAD\",\n TAppContext extends Record<string, unknown> = AppContext,\n> = {\n <const Path extends RoutePath>(\n path: Path,\n ): RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;\n <\n const Path extends RoutePath,\n TQuery = unknown,\n TParams = unknown,\n TQueryIn = unknown,\n TParamsIn = unknown,\n >(\n path: Path,\n options: WithoutBodyOptions<TQuery, TParams, TQueryIn, TParamsIn>,\n ): RouteBuilder<\n Path,\n M,\n readonly [],\n {\n query: TQuery;\n params: TParams;\n queryIn: TQueryIn;\n paramsIn: TParamsIn;\n },\n {},\n TAppContext\n >;\n};\n\nexport type CreateWithBodyRoute<\n M extends \"POST\" | \"PUT\" | \"PATCH\",\n TAppContext extends Record<string, unknown> = AppContext,\n> = {\n <const Path extends RoutePath>(\n path: Path,\n ): RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;\n <\n const Path extends RoutePath,\n TQuery = unknown,\n TParams = unknown,\n TBody = unknown,\n TQueryIn = unknown,\n TParamsIn = unknown,\n TBodyIn = unknown,\n >(\n path: Path,\n options: WithBodyOptions<TQuery, TParams, TBody, TQueryIn, TParamsIn, TBodyIn>,\n ): RouteBuilder<\n Path,\n M,\n readonly [],\n {\n query: TQuery;\n params: TParams;\n body: TBody;\n queryIn: TQueryIn;\n paramsIn: TParamsIn;\n bodyIn: TBodyIn;\n },\n {},\n TAppContext\n >;\n};\n\nexport type CreateAnyRoute<TAppContext extends Record<string, unknown> = AppContext> = {\n <const Path extends RoutePath, const Methods extends readonly HttpMethod[]>(\n path: Path,\n methods: Methods,\n ): RouteBuilder<Path, Methods[number], readonly [], {}, {}, TAppContext>;\n <\n const Path extends RoutePath,\n const Methods extends readonly HttpMethod[],\n TQuery = unknown,\n TParams = unknown,\n TBody = unknown,\n TQueryIn = unknown,\n TParamsIn = unknown,\n TBodyIn = unknown,\n >(\n path: Path,\n methods: Methods,\n options: WithBodyOptions<TQuery, TParams, TBody, TQueryIn, TParamsIn, TBodyIn>,\n ): RouteBuilder<\n Path,\n Methods[number],\n readonly [],\n {\n query: TQuery;\n params: TParams;\n body: TBody;\n queryIn: TQueryIn;\n paramsIn: TParamsIn;\n bodyIn: TBodyIn;\n },\n {},\n TAppContext\n >;\n};\n\nexport type CreateAllRoute<TAppContext extends Record<string, unknown> = AppContext> = {\n <const Path extends RoutePath>(\n path: Path,\n ): RouteBuilder<Path, HttpMethod, readonly [], {}, {}, TAppContext>;\n <\n const Path extends RoutePath,\n TQuery = unknown,\n TParams = unknown,\n TBody = unknown,\n TQueryIn = unknown,\n TParamsIn = unknown,\n TBodyIn = unknown,\n >(\n path: Path,\n options: WithBodyOptions<TQuery, TParams, TBody, TQueryIn, TParamsIn, TBodyIn>,\n ): RouteBuilder<\n Path,\n HttpMethod,\n readonly [],\n {\n query: TQuery;\n params: TParams;\n body: TBody;\n queryIn: TQueryIn;\n paramsIn: TParamsIn;\n bodyIn: TBodyIn;\n },\n {},\n TAppContext\n >;\n};\n\nfunction createWithoutBodyRoute<M extends \"GET\" | \"DELETE\" | \"OPTIONS\" | \"HEAD\">(\n method: M,\n): CreateWithoutBodyRoute<M> {\n return ((path: string, options?: WithoutBodyOptions<unknown, unknown>) =>\n createRouteBuilder(path, method, options)) as unknown as CreateWithoutBodyRoute<M>;\n}\n\nfunction createWithBodyRoute<M extends \"POST\" | \"PUT\" | \"PATCH\">(\n method: M,\n): CreateWithBodyRoute<M> {\n return ((path: string, options?: WithBodyOptions<unknown, unknown, unknown>) =>\n createRouteBuilder(path, method, options)) as unknown as CreateWithBodyRoute<M>;\n}\n\nexport const createGetRoute = createWithoutBodyRoute(\"GET\");\nexport const createDeleteRoute = createWithoutBodyRoute(\"DELETE\");\nexport const createOptionsRoute = createWithoutBodyRoute(\"OPTIONS\");\nexport const createHeadRoute = createWithoutBodyRoute(\"HEAD\");\nexport const createPostRoute = createWithBodyRoute(\"POST\");\nexport const createPutRoute = createWithBodyRoute(\"PUT\");\nexport const createPatchRoute = createWithBodyRoute(\"PATCH\");\n\nexport const createAnyRoute: CreateAnyRoute = ((\n path: string,\n methods: readonly HttpMethod[],\n options?: WithBodyOptions<unknown, unknown, unknown>,\n) => createRouteBuilder(path, \"ANY\", options, methods)) as unknown as CreateAnyRoute;\n\nexport const createAllRoute: CreateAllRoute = ((\n path: string,\n options?: WithBodyOptions<unknown, unknown, unknown>,\n) => createRouteBuilder(path, \"ALL\", options)) as unknown as CreateAllRoute;\n"],"mappings":";;AAyJA,SAAS,uBACP,QAC2B;CAC3B,SAAS,MAAc,YACrB,mBAAmB,MAAM,QAAQ,OAAO;AAC5C;AAEA,SAAS,oBACP,QACwB;CACxB,SAAS,MAAc,YACrB,mBAAmB,MAAM,QAAQ,OAAO;AAC5C;AAEA,IAAa,iBAAiB,uBAAuB,KAAK;AAC1D,IAAa,oBAAoB,uBAAuB,QAAQ;AAChE,IAAa,qBAAqB,uBAAuB,SAAS;AAClE,IAAa,kBAAkB,uBAAuB,MAAM;AAC5D,IAAa,kBAAkB,oBAAoB,MAAM;AACzD,IAAa,iBAAiB,oBAAoB,KAAK;AACvD,IAAa,mBAAmB,oBAAoB,OAAO;AAE3D,IAAa,mBACX,MACA,SACA,YACG,mBAAmB,MAAM,OAAO,SAAS,OAAO;AAErD,IAAa,mBACX,MACA,YACG,mBAAmB,MAAM,OAAO,OAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"middleware.js","names":[],"sources":["../../src/middleware.ts"],"sourcesContent":["import type { LayoutId, MiddlewareBuilder } from \"./types/index.js\";\nimport type { MiddlewareDefinition } from \"./types/units.js\";\n\nexport function createMiddleware<const Layout extends LayoutId>(\n layout: Layout,\n): MiddlewareBuilder<Layout, readonly []> {\n const entries: MiddlewareDefinition[] = [];\n\n const chain = {\n layout,\n middlewares: entries,\n use(definition: MiddlewareDefinition) {\n entries.push(definition);\n return chain;\n },\n };\n\n return chain as unknown as MiddlewareBuilder<Layout, readonly []>;\n}\n"],"mappings":";AAGA,SAAgB,iBACd,QACwC;CACxC,MAAM,UAAkC,CAAC;CAEzC,MAAM,QAAQ;EACZ;EACA,aAAa;EACb,IAAI,YAAkC;GACpC,QAAQ,KAAK,UAAU;GACvB,OAAO;EACT;CACF;CAEA,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"route.js","names":[],"sources":["../../src/route.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport {\n collectReturnsFromDefinitions,\n hasInputSchemas,\n mergeReturnsMaps,\n withAuto422,\n} from \"@taserjs/router-utils\";\n\nimport type { Method, RouteBuilder, RoutePath, ReturnsMap, ValidatorParts } from \"./types/index.js\";\nimport type { HttpMethod, MiddlewareDefinition } from \"./types/units.js\";\nimport { isHandlerUnit } from \"./types/units.js\";\nimport { HANDLER_SCHEMA_KEY_MAP } from \"./constants.js\";\nimport { pickDefinedSchemas, type SchemaValidators } from \"./define/validators.js\";\n\nfunction toUtilsMap(map: ReturnsMap | undefined): Record<number, StandardSchemaV1> {\n if (!map) {\n return {};\n }\n const out: Record<number, StandardSchemaV1> = {};\n for (const [key, schema] of Object.entries(map)) {\n if (schema !== undefined) {\n out[Number(key)] = schema;\n }\n }\n return out;\n}\n\nfunction buildEffectiveReturns(args: {\n middlewareReturns: ReturnsMap;\n routeReturns: ReturnsMap;\n handlerMiddlewareReturns: ReturnsMap;\n handlerReturns: ReturnsMap | undefined;\n schemas: {\n query?: unknown;\n params?: unknown;\n body?: unknown;\n handlerQuery?: unknown;\n handlerParams?: unknown;\n handlerBody?: unknown;\n middlewares?: readonly MiddlewareDefinition[];\n handlerMiddlewares?: readonly MiddlewareDefinition[];\n };\n}): Record<number, StandardSchemaV1> | undefined {\n const merged = mergeReturnsMaps(\n toUtilsMap(args.middlewareReturns),\n toUtilsMap(args.routeReturns),\n toUtilsMap(args.handlerMiddlewareReturns),\n toUtilsMap(args.handlerReturns),\n );\n const with422 = withAuto422(merged, hasInputSchemas(args.schemas));\n return Object.keys(with422).length > 0 ? with422 : undefined;\n}\n\nfunction buildRouteBase(\n path: string,\n method: HttpMethod | \"ANY\" | \"ALL\",\n methods: readonly HttpMethod[] | undefined,\n middlewares: MiddlewareDefinition[],\n) {\n return {\n path,\n method,\n ...(methods ? { methods: [...methods] } : {}),\n middlewares: [...middlewares],\n };\n}\n\n/** Shared internal builder — not part of the public `@taserjs/router` API. */\nexport function createRouteBuilder(\n path: string,\n method: HttpMethod | \"ANY\" | \"ALL\",\n validators: SchemaValidators = {},\n methods?: readonly HttpMethod[],\n): RouteBuilder<RoutePath, Method, readonly [], ValidatorParts> {\n const middlewares: MiddlewareDefinition[] = [];\n let routeReturns: Record<number, StandardSchemaV1> = {};\n\n const builder = {\n path,\n method,\n returns(map: ReturnsMap) {\n routeReturns = { ...routeReturns, ...toUtilsMap(map) };\n return builder;\n },\n use(definition: MiddlewareDefinition) {\n middlewares.push(definition);\n return builder;\n },\n handler(fnOrUnit: ((ctx: unknown) => unknown) | unknown) {\n const routeSchemas = pickDefinedSchemas(validators);\n const base = buildRouteBase(path, method, methods, middlewares);\n\n if (isHandlerUnit(fnOrUnit)) {\n const handlerSchemas = pickDefinedSchemas(fnOrUnit, HANDLER_SCHEMA_KEY_MAP);\n const returns = buildEffectiveReturns({\n middlewareReturns: collectReturnsFromDefinitions(middlewares),\n routeReturns: routeReturns,\n handlerMiddlewareReturns: collectReturnsFromDefinitions(fnOrUnit.middlewares),\n handlerReturns: fnOrUnit.returns,\n schemas: {\n ...validators,\n handlerQuery: fnOrUnit.query,\n handlerParams: fnOrUnit.params,\n handlerBody: fnOrUnit.body,\n middlewares,\n handlerMiddlewares: fnOrUnit.middlewares,\n },\n });\n\n return {\n ...base,\n handlerMiddlewares: [...fnOrUnit.middlewares],\n handler: fnOrUnit.handler,\n ...routeSchemas,\n ...handlerSchemas,\n ...(returns ? { returns } : {}),\n };\n }\n\n const returns = buildEffectiveReturns({\n middlewareReturns: collectReturnsFromDefinitions(middlewares),\n routeReturns: routeReturns,\n handlerMiddlewareReturns: {},\n handlerReturns: undefined,\n schemas: {\n ...validators,\n middlewares,\n },\n });\n\n return {\n ...base,\n handlerMiddlewares: [],\n handler: fnOrUnit as (ctx: unknown) => Response | Promise<Response>,\n ...routeSchemas,\n ...(returns ? { returns } : {}),\n };\n },\n };\n\n return builder as unknown as RouteBuilder<RoutePath, Method, readonly [], ValidatorParts>;\n}\n"],"mappings":";;;;;AAcA,SAAS,WAAW,KAA+D;CACjF,IAAI,CAAC,KACH,OAAO,CAAC;CAEV,MAAM,MAAwC,CAAC;CAC/C,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,GAAG,GAC5C,IAAI,WAAW,KAAA,GACb,IAAI,OAAO,GAAG,KAAK;CAGvB,OAAO;AACT;AAEA,SAAS,sBAAsB,MAekB;CAO/C,MAAM,UAAU,YAND,iBACb,WAAW,KAAK,iBAAiB,GACjC,WAAW,KAAK,YAAY,GAC5B,WAAW,KAAK,wBAAwB,GACxC,WAAW,KAAK,cAAc,CAEJ,GAAQ,gBAAgB,KAAK,OAAO,CAAC;CACjE,OAAO,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,IAAI,UAAU,KAAA;AACrD;AAEA,SAAS,eACP,MACA,QACA,SACA,aACA;CACA,OAAO;EACL;EACA;EACA,GAAI,UAAU,EAAE,SAAS,CAAC,GAAG,OAAO,EAAE,IAAI,CAAC;EAC3C,aAAa,CAAC,GAAG,WAAW;CAC9B;AACF;;AAGA,SAAgB,mBACd,MACA,QACA,aAA+B,CAAC,GAChC,SAC8D;CAC9D,MAAM,cAAsC,CAAC;CAC7C,IAAI,eAAiD,CAAC;CAEtD,MAAM,UAAU;EACd;EACA;EACA,QAAQ,KAAiB;GACvB,eAAe;IAAE,GAAG;IAAc,GAAG,WAAW,GAAG;GAAE;GACrD,OAAO;EACT;EACA,IAAI,YAAkC;GACpC,YAAY,KAAK,UAAU;GAC3B,OAAO;EACT;EACA,QAAQ,UAAiD;GACvD,MAAM,eAAe,mBAAmB,UAAU;GAClD,MAAM,OAAO,eAAe,MAAM,QAAQ,SAAS,WAAW;GAE9D,IAAI,cAAc,QAAQ,GAAG;IAC3B,MAAM,iBAAiB,mBAAmB,UAAU,sBAAsB;IAC1E,MAAM,UAAU,sBAAsB;KACpC,mBAAmB,8BAA8B,WAAW;KAC9C;KACd,0BAA0B,8BAA8B,SAAS,WAAW;KAC5E,gBAAgB,SAAS;KACzB,SAAS;MACP,GAAG;MACH,cAAc,SAAS;MACvB,eAAe,SAAS;MACxB,aAAa,SAAS;MACtB;MACA,oBAAoB,SAAS;KAC/B;IACF,CAAC;IAED,OAAO;KACL,GAAG;KACH,oBAAoB,CAAC,GAAG,SAAS,WAAW;KAC5C,SAAS,SAAS;KAClB,GAAG;KACH,GAAG;KACH,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;IAC/B;GACF;GAEA,MAAM,UAAU,sBAAsB;IACpC,mBAAmB,8BAA8B,WAAW;IAC9C;IACd,0BAA0B,CAAC;IAC3B,gBAAgB,KAAA;IAChB,SAAS;KACP,GAAG;KACH;IACF;GACF,CAAC;GAED,OAAO;IACL,GAAG;IACH,oBAAoB,CAAC;IACrB,SAAS;IACT,GAAG;IACH,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;GAC/B;EACF;CACF;CAEA,OAAO;AACT"}
@@ -1,18 +0,0 @@
1
- import { TaserRuntime, RouteManifestShape } from '@taserjs/router-core';
2
- declare class TaserServeView {
3
- protected readonly runtime: TaserRuntime;
4
- constructor(runtime: TaserRuntime);
5
- fetch(request: Request, env?: unknown, executionCtx?: unknown): Promise<Response>;
6
- native(native: unknown): TaserNativeBound;
7
- }
8
- export declare class TaserNativeBound {
9
- private readonly runtime;
10
- private readonly boundNative;
11
- constructor(runtime: TaserRuntime, boundNative: unknown);
12
- fetch(request: Request, env?: unknown, executionCtx?: unknown): Promise<Response>;
13
- }
14
- export declare class TaserApp<TManifest extends RouteManifestShape = RouteManifestShape> extends TaserServeView {
15
- readonly __manifest?: TManifest;
16
- constructor(runtime: TaserRuntime, manifest?: TManifest);
17
- }
18
- export {};
@@ -1,35 +0,0 @@
1
- //#region src/taser-app.ts
2
- var TaserServeView = class {
3
- runtime;
4
- constructor(runtime) {
5
- this.runtime = runtime;
6
- }
7
- fetch(request, env, executionCtx) {
8
- return this.runtime.fetch(request, env, executionCtx);
9
- }
10
- native(native) {
11
- return new TaserNativeBound(this.runtime, native);
12
- }
13
- };
14
- var TaserNativeBound = class {
15
- runtime;
16
- boundNative;
17
- constructor(runtime, boundNative) {
18
- this.runtime = runtime;
19
- this.boundNative = boundNative;
20
- }
21
- fetch(request, env, executionCtx) {
22
- return this.runtime.native(this.boundNative).fetch(request, env, executionCtx);
23
- }
24
- };
25
- var TaserApp = class extends TaserServeView {
26
- __manifest;
27
- constructor(runtime, manifest) {
28
- super(runtime);
29
- if (manifest !== void 0) this.__manifest = manifest;
30
- }
31
- };
32
- //#endregion
33
- export { TaserApp, TaserNativeBound };
34
-
35
- //# sourceMappingURL=taser-app.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"taser-app.js","names":[],"sources":["../../src/taser-app.ts"],"sourcesContent":["import type { TaserRuntime } from \"@taserjs/router-core\";\nimport type { RouteManifestShape } from \"@taserjs/router-core\";\n\nclass TaserServeView {\n constructor(protected readonly runtime: TaserRuntime) {}\n\n fetch(request: Request, env?: unknown, executionCtx?: unknown): Promise<Response> {\n return this.runtime.fetch(request, env, executionCtx as never);\n }\n\n native(native: unknown): TaserNativeBound {\n return new TaserNativeBound(this.runtime, native);\n }\n}\n\nexport class TaserNativeBound {\n constructor(\n private readonly runtime: TaserRuntime,\n private readonly boundNative: unknown,\n ) {}\n\n fetch(request: Request, env?: unknown, executionCtx?: unknown): Promise<Response> {\n return this.runtime.native(this.boundNative).fetch(request, env, executionCtx as never);\n }\n}\n\nexport class TaserApp<\n TManifest extends RouteManifestShape = RouteManifestShape,\n> extends TaserServeView {\n readonly __manifest?: TManifest;\n\n constructor(runtime: TaserRuntime, manifest?: TManifest) {\n super(runtime);\n if (manifest !== undefined) {\n this.__manifest = manifest;\n }\n }\n}\n"],"mappings":";AAGA,IAAM,iBAAN,MAAqB;CACY;CAA/B,YAAY,SAA0C;EAAvB,KAAA,UAAA;CAAwB;CAEvD,MAAM,SAAkB,KAAe,cAA2C;EAChF,OAAO,KAAK,QAAQ,MAAM,SAAS,KAAK,YAAqB;CAC/D;CAEA,OAAO,QAAmC;EACxC,OAAO,IAAI,iBAAiB,KAAK,SAAS,MAAM;CAClD;AACF;AAEA,IAAa,mBAAb,MAA8B;CAET;CACA;CAFnB,YACE,SACA,aACA;EAFiB,KAAA,UAAA;EACA,KAAA,cAAA;CAChB;CAEH,MAAM,SAAkB,KAAe,cAA2C;EAChF,OAAO,KAAK,QAAQ,OAAO,KAAK,WAAW,CAAC,CAAC,MAAM,SAAS,KAAK,YAAqB;CACxF;AACF;AAEA,IAAa,WAAb,cAEU,eAAe;CACvB;CAEA,YAAY,SAAuB,UAAsB;EACvD,MAAM,OAAO;EACb,IAAI,aAAa,KAAA,GACf,KAAK,aAAa;CAEtB;AACF"}
@@ -1,42 +0,0 @@
1
- import { NotFoundHandler, OnErrorHandler, RouteManifestShape } from '@taserjs/router-core';
2
- import { TaserApp } from './taser-app.js';
3
- import { ContextDefinition, CreateTaserAppOptions, OnErrorOptions } from './types/app.js';
4
- import { AppContext } from './types/units.js';
5
- import { HandlerBuilder, LayoutId, MiddlewareBuilder } from './types/index.js';
6
- import { Schema } from './types/schema.js';
7
- import { CreateAllRoute, CreateAnyRoute, CreateWithBodyRoute, CreateWithoutBodyRoute } from './factories.js';
8
- type RouterState = {
9
- options: CreateTaserAppOptions;
10
- contextDef: ContextDefinition<Record<string, unknown>, Record<string, unknown>>;
11
- onError?: OnErrorHandler;
12
- notFound?: NotFoundHandler;
13
- };
14
- export declare class TaserRouter<TAppContext extends Record<string, unknown> = AppContext> {
15
- private readonly state;
16
- constructor(options?: CreateTaserAppOptions, state?: Partial<Omit<RouterState, "options">>);
17
- context<TBoot extends Record<string, unknown>, TReq extends Record<string, unknown>>(definition: ContextDefinition<TBoot, TReq>): TaserRouter<TBoot & TReq>;
18
- onError<TResponses extends import('./types/returns.js').ReturnsMap = import('./types/returns.js').ReturnsMap>(options: OnErrorOptions<TResponses> | OnErrorOptions<TResponses>["handle"]): this;
19
- notFound(handler: (ctx: unknown) => Response | Promise<Response> | unknown): this;
20
- get: CreateWithoutBodyRoute<"GET", TAppContext>;
21
- post: CreateWithBodyRoute<"POST", TAppContext>;
22
- put: CreateWithBodyRoute<"PUT", TAppContext>;
23
- patch: CreateWithBodyRoute<"PATCH", TAppContext>;
24
- delete: CreateWithoutBodyRoute<"DELETE", TAppContext>;
25
- options: CreateWithoutBodyRoute<"OPTIONS", TAppContext>;
26
- head: CreateWithoutBodyRoute<"HEAD", TAppContext>;
27
- any: CreateAnyRoute<TAppContext>;
28
- all: CreateAllRoute<TAppContext>;
29
- middleware<const Layout extends LayoutId>(layout: Layout): MiddlewareBuilder<Layout, readonly [], TAppContext>;
30
- defineHandler<TQuery = unknown, TParams = unknown, TBody = unknown>(options?: {
31
- query?: Schema<TQuery>;
32
- params?: Schema<TParams>;
33
- body?: Schema<TBody>;
34
- }): HandlerBuilder<readonly [], {
35
- query: TQuery;
36
- params: TParams;
37
- body: TBody;
38
- }, {}, TAppContext>;
39
- create<const TManifest extends RouteManifestShape>(manifest: TManifest): TaserApp<TManifest>;
40
- }
41
- export declare function createTaserApp(options?: CreateTaserAppOptions): TaserRouter;
42
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"taser-router.js","names":[],"sources":["../../src/taser-router.ts"],"sourcesContent":["import {\n createTaserRuntime,\n type NotFoundHandler,\n type OnErrorHandler,\n type RouteManifestShape,\n} from \"@taserjs/router-core\";\nimport { normalizeOnError } from \"@taserjs/router-utils\";\n\nimport {\n createAllRoute,\n createAnyRoute,\n createDeleteRoute,\n createGetRoute,\n createHeadRoute,\n createOptionsRoute,\n createPatchRoute,\n createPostRoute,\n createPutRoute,\n} from \"./factories.js\";\nimport { defineHandler } from \"./define/handler.js\";\nimport { createMiddleware } from \"./middleware.js\";\nimport { TaserApp } from \"./taser-app.js\";\nimport type { ContextDefinition, CreateTaserAppOptions, OnErrorOptions } from \"./types/app.js\";\nimport type { AppContext } from \"./types/units.js\";\nimport type { HandlerBuilder, LayoutId, MiddlewareBuilder } from \"./types/index.js\";\nimport type { Schema } from \"./types/schema.js\";\nimport type {\n CreateAllRoute,\n CreateAnyRoute,\n CreateWithBodyRoute,\n CreateWithoutBodyRoute,\n} from \"./factories.js\";\n\nfunction toOnErrorHandler(\n onErrorOptions: OnErrorOptions | OnErrorOptions[\"handle\"],\n): OnErrorHandler {\n return normalizeOnError(onErrorOptions);\n}\n\ntype RouterState = {\n options: CreateTaserAppOptions;\n contextDef: ContextDefinition<Record<string, unknown>, Record<string, unknown>>;\n onError?: OnErrorHandler;\n notFound?: NotFoundHandler;\n};\n\nconst emptyContext: ContextDefinition<Record<string, unknown>, Record<string, unknown>> = {};\n\nexport class TaserRouter<TAppContext extends Record<string, unknown> = AppContext> {\n private readonly state: RouterState;\n\n constructor(options: CreateTaserAppOptions = {}, state?: Partial<Omit<RouterState, \"options\">>) {\n this.state = {\n options,\n contextDef: state?.contextDef ?? emptyContext,\n ...(state?.onError !== undefined ? { onError: state.onError } : {}),\n ...(state?.notFound !== undefined ? { notFound: state.notFound } : {}),\n };\n }\n\n context<TBoot extends Record<string, unknown>, TReq extends Record<string, unknown>>(\n definition: ContextDefinition<TBoot, TReq>,\n ): TaserRouter<TBoot & TReq> {\n this.state.contextDef = definition;\n return this as unknown as TaserRouter<TBoot & TReq>;\n }\n\n onError<\n TResponses extends import(\"./types/returns.js\").ReturnsMap =\n import(\"./types/returns.js\").ReturnsMap,\n >(options: OnErrorOptions<TResponses> | OnErrorOptions<TResponses>[\"handle\"]): this {\n this.state.onError = toOnErrorHandler(options);\n return this;\n }\n\n notFound(handler: (ctx: unknown) => Response | Promise<Response> | unknown): this {\n this.state.notFound = (ctx) => handler(ctx);\n return this;\n }\n\n get: CreateWithoutBodyRoute<\"GET\", TAppContext> = createGetRoute as CreateWithoutBodyRoute<\n \"GET\",\n TAppContext\n >;\n post: CreateWithBodyRoute<\"POST\", TAppContext> = createPostRoute as CreateWithBodyRoute<\n \"POST\",\n TAppContext\n >;\n put: CreateWithBodyRoute<\"PUT\", TAppContext> = createPutRoute as CreateWithBodyRoute<\n \"PUT\",\n TAppContext\n >;\n patch: CreateWithBodyRoute<\"PATCH\", TAppContext> = createPatchRoute as CreateWithBodyRoute<\n \"PATCH\",\n TAppContext\n >;\n delete: CreateWithoutBodyRoute<\"DELETE\", TAppContext> =\n createDeleteRoute as CreateWithoutBodyRoute<\"DELETE\", TAppContext>;\n options: CreateWithoutBodyRoute<\"OPTIONS\", TAppContext> =\n createOptionsRoute as CreateWithoutBodyRoute<\"OPTIONS\", TAppContext>;\n head: CreateWithoutBodyRoute<\"HEAD\", TAppContext> = createHeadRoute as CreateWithoutBodyRoute<\n \"HEAD\",\n TAppContext\n >;\n any: CreateAnyRoute<TAppContext> = createAnyRoute as CreateAnyRoute<TAppContext>;\n all: CreateAllRoute<TAppContext> = createAllRoute as CreateAllRoute<TAppContext>;\n\n middleware<const Layout extends LayoutId>(\n layout: Layout,\n ): MiddlewareBuilder<Layout, readonly [], TAppContext> {\n return createMiddleware(layout) as MiddlewareBuilder<Layout, readonly [], TAppContext>;\n }\n\n defineHandler<TQuery = unknown, TParams = unknown, TBody = unknown>(options?: {\n query?: Schema<TQuery>;\n params?: Schema<TParams>;\n body?: Schema<TBody>;\n }): HandlerBuilder<\n readonly [],\n { query: TQuery; params: TParams; body: TBody },\n {},\n TAppContext\n > {\n return options === undefined\n ? defineHandler<TAppContext>()\n : defineHandler<TAppContext>(options);\n }\n\n create<const TManifest extends RouteManifestShape>(manifest: TManifest): TaserApp<TManifest> {\n const definition = this.state.contextDef;\n const validateResponse = this.state.options.response?.validate ?? true;\n const onValidationFailure = this.state.options.response?.onValidationFailure;\n const basePath = this.state.options.basePath;\n\n const hasCustomContext = definition.boot !== undefined || definition.request !== undefined;\n const bootPromise = hasCustomContext\n ? Promise.resolve(definition.boot?.() ?? ({} as Record<string, unknown>))\n : undefined;\n\n const contextFactory = hasCustomContext\n ? async ({ native }: { native?: unknown } = {}) => {\n const bootContext = (await bootPromise) ?? {};\n const requestContext = (await definition.request?.({ native: native as never })) ?? {};\n return { ...bootContext, ...requestContext };\n }\n : () => ({});\n\n const runtime = createTaserRuntime(manifest, contextFactory, {\n ...(basePath !== undefined ? { basePath } : {}),\n response: {\n validate: validateResponse,\n ...(onValidationFailure !== undefined ? { onValidationFailure } : {}),\n },\n ...(this.state.onError !== undefined ? { onError: this.state.onError } : {}),\n ...(this.state.notFound !== undefined ? { notFound: this.state.notFound } : {}),\n ...(this.state.options.cookies !== undefined ? { cookies: this.state.options.cookies } : {}),\n });\n\n return new TaserApp(runtime, manifest);\n }\n}\n\nexport function createTaserApp(options: CreateTaserAppOptions = {}): TaserRouter {\n return new TaserRouter(options);\n}\n"],"mappings":";;;;;;;AAiCA,SAAS,iBACP,gBACgB;CAChB,OAAO,iBAAiB,cAAc;AACxC;AASA,IAAM,eAAoF,CAAC;AAE3F,IAAa,cAAb,MAAmF;CACjF;CAEA,YAAY,UAAiC,CAAC,GAAG,OAA+C;EAC9F,KAAK,QAAQ;GACX;GACA,YAAY,OAAO,cAAc;GACjC,GAAI,OAAO,YAAY,KAAA,IAAY,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;GACjE,GAAI,OAAO,aAAa,KAAA,IAAY,EAAE,UAAU,MAAM,SAAS,IAAI,CAAC;EACtE;CACF;CAEA,QACE,YAC2B;EAC3B,KAAK,MAAM,aAAa;EACxB,OAAO;CACT;CAEA,QAGE,SAAkF;EAClF,KAAK,MAAM,UAAU,iBAAiB,OAAO;EAC7C,OAAO;CACT;CAEA,SAAS,SAAyE;EAChF,KAAK,MAAM,YAAY,QAAQ,QAAQ,GAAG;EAC1C,OAAO;CACT;CAEA,MAAkD;CAIlD,OAAiD;CAIjD,MAA+C;CAI/C,QAAmD;CAInD,SACE;CACF,UACE;CACF,OAAoD;CAIpD,MAAmC;CACnC,MAAmC;CAEnC,WACE,QACqD;EACrD,OAAO,iBAAiB,MAAM;CAChC;CAEA,cAAoE,SASlE;EACA,OAAO,YAAY,KAAA,IACf,cAA2B,IAC3B,cAA2B,OAAO;CACxC;CAEA,OAAmD,UAA0C;EAC3F,MAAM,aAAa,KAAK,MAAM;EAC9B,MAAM,mBAAmB,KAAK,MAAM,QAAQ,UAAU,YAAY;EAClE,MAAM,sBAAsB,KAAK,MAAM,QAAQ,UAAU;EACzD,MAAM,WAAW,KAAK,MAAM,QAAQ;EAEpC,MAAM,mBAAmB,WAAW,SAAS,KAAA,KAAa,WAAW,YAAY,KAAA;EACjF,MAAM,cAAc,mBAChB,QAAQ,QAAQ,WAAW,OAAO,KAAM,CAAC,CAA6B,IACtE,KAAA;EAqBJ,OAAO,IAAI,SAXK,mBAAmB,UARZ,mBACnB,OAAO,EAAE,WAAiC,CAAC,MAAM;GAC/C,MAAM,cAAe,MAAM,eAAgB,CAAC;GAC5C,MAAM,iBAAkB,MAAM,WAAW,UAAU,EAAU,OAAgB,CAAC,KAAM,CAAC;GACrF,OAAO;IAAE,GAAG;IAAa,GAAG;GAAe;EAC7C,WACO,CAAC,IAEiD;GAC3D,GAAI,aAAa,KAAA,IAAY,EAAE,SAAS,IAAI,CAAC;GAC7C,UAAU;IACR,UAAU;IACV,GAAI,wBAAwB,KAAA,IAAY,EAAE,oBAAoB,IAAI,CAAC;GACrE;GACA,GAAI,KAAK,MAAM,YAAY,KAAA,IAAY,EAAE,SAAS,KAAK,MAAM,QAAQ,IAAI,CAAC;GAC1E,GAAI,KAAK,MAAM,aAAa,KAAA,IAAY,EAAE,UAAU,KAAK,MAAM,SAAS,IAAI,CAAC;GAC7E,GAAI,KAAK,MAAM,QAAQ,YAAY,KAAA,IAAY,EAAE,SAAS,KAAK,MAAM,QAAQ,QAAQ,IAAI,CAAC;EAC5F,CAEoB,GAAS,QAAQ;CACvC;AACF;AAEA,SAAgB,eAAe,UAAiC,CAAC,GAAgB;CAC/E,OAAO,IAAI,YAAY,OAAO;AAChC"}
package/src/taser-app.ts DELETED
@@ -1,38 +0,0 @@
1
- import type { TaserRuntime } from "@taserjs/router-core";
2
- import type { RouteManifestShape } from "@taserjs/router-core";
3
-
4
- class TaserServeView {
5
- constructor(protected readonly runtime: TaserRuntime) {}
6
-
7
- fetch(request: Request, env?: unknown, executionCtx?: unknown): Promise<Response> {
8
- return this.runtime.fetch(request, env, executionCtx as never);
9
- }
10
-
11
- native(native: unknown): TaserNativeBound {
12
- return new TaserNativeBound(this.runtime, native);
13
- }
14
- }
15
-
16
- export class TaserNativeBound {
17
- constructor(
18
- private readonly runtime: TaserRuntime,
19
- private readonly boundNative: unknown,
20
- ) {}
21
-
22
- fetch(request: Request, env?: unknown, executionCtx?: unknown): Promise<Response> {
23
- return this.runtime.native(this.boundNative).fetch(request, env, executionCtx as never);
24
- }
25
- }
26
-
27
- export class TaserApp<
28
- TManifest extends RouteManifestShape = RouteManifestShape,
29
- > extends TaserServeView {
30
- readonly __manifest?: TManifest;
31
-
32
- constructor(runtime: TaserRuntime, manifest?: TManifest) {
33
- super(runtime);
34
- if (manifest !== undefined) {
35
- this.__manifest = manifest;
36
- }
37
- }
38
- }