@taserjs/router 0.0.1 → 0.0.3

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 (142) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/constants.cjs.map +1 -1
  3. package/dist/cjs/create-context.cjs.map +1 -1
  4. package/dist/cjs/define/handler.cjs.map +1 -1
  5. package/dist/cjs/define/middleware.cjs +5 -24
  6. package/dist/cjs/define/middleware.cjs.map +1 -1
  7. package/dist/cjs/define/middleware.d.cts +10 -79
  8. package/dist/cjs/define/validators.cjs.map +1 -1
  9. package/dist/cjs/factories.cjs.map +1 -1
  10. package/dist/cjs/factories.d.cts +2 -2
  11. package/dist/cjs/index.cjs +7 -2
  12. package/dist/cjs/index.d.cts +2 -2
  13. package/dist/cjs/middleware/body-limit.cjs +2 -2
  14. package/dist/cjs/middleware/body-limit.cjs.map +1 -1
  15. package/dist/cjs/middleware/compress.cjs +2 -2
  16. package/dist/cjs/middleware/compress.cjs.map +1 -1
  17. package/dist/cjs/middleware/cors.cjs +2 -2
  18. package/dist/cjs/middleware/cors.cjs.map +1 -1
  19. package/dist/cjs/middleware/csrf.cjs +2 -2
  20. package/dist/cjs/middleware/csrf.cjs.map +1 -1
  21. package/dist/cjs/middleware/etag.cjs +2 -2
  22. package/dist/cjs/middleware/etag.cjs.map +1 -1
  23. package/dist/cjs/middleware/jwk.cjs +11 -4
  24. package/dist/cjs/middleware/jwk.cjs.map +1 -1
  25. package/dist/cjs/middleware/jwk.d.cts +4 -5
  26. package/dist/cjs/middleware/jwt.cjs +11 -5
  27. package/dist/cjs/middleware/jwt.cjs.map +1 -1
  28. package/dist/cjs/middleware/jwt.d.cts +7 -5
  29. package/dist/cjs/middleware/secure-headers.cjs +2 -2
  30. package/dist/cjs/middleware/secure-headers.cjs.map +1 -1
  31. package/dist/cjs/middleware/timing.cjs +2 -2
  32. package/dist/cjs/middleware/timing.cjs.map +1 -1
  33. package/dist/cjs/middleware/wrap-hono.cjs +9 -0
  34. package/dist/cjs/middleware/wrap-hono.cjs.map +1 -0
  35. package/dist/cjs/middleware/wrap-hono.d.cts +3 -0
  36. package/dist/cjs/middleware.cjs.map +1 -1
  37. package/dist/cjs/reply.cjs +20 -0
  38. package/dist/cjs/reply.d.cts +2 -0
  39. package/dist/cjs/route.cjs.map +1 -1
  40. package/dist/cjs/route.d.cts +1 -1
  41. package/dist/cjs/stream.cjs +32 -0
  42. package/dist/cjs/stream.d.cts +1 -0
  43. package/dist/cjs/taser-app.cjs +0 -6
  44. package/dist/cjs/taser-app.cjs.map +1 -1
  45. package/dist/cjs/taser-app.d.cts +0 -3
  46. package/dist/cjs/taser-router.cjs +9 -10
  47. package/dist/cjs/taser-router.cjs.map +1 -1
  48. package/dist/cjs/taser-router.d.cts +9 -11
  49. package/dist/cjs/types/app.d.cts +3 -2
  50. package/dist/cjs/types/index.d.cts +53 -139
  51. package/dist/cjs/types/type-utils.d.cts +8 -11
  52. package/dist/cjs/types/units.cjs.map +1 -1
  53. package/dist/cjs/types/units.d.cts +27 -24
  54. package/dist/esm/constants.js.map +1 -1
  55. package/dist/esm/create-context.js.map +1 -1
  56. package/dist/esm/define/handler.js.map +1 -1
  57. package/dist/esm/define/middleware.d.ts +10 -79
  58. package/dist/esm/define/middleware.js +5 -24
  59. package/dist/esm/define/middleware.js.map +1 -1
  60. package/dist/esm/define/validators.js.map +1 -1
  61. package/dist/esm/factories.d.ts +2 -2
  62. package/dist/esm/factories.js.map +1 -1
  63. package/dist/esm/index.d.ts +2 -2
  64. package/dist/esm/index.js +4 -4
  65. package/dist/esm/middleware/body-limit.js +1 -1
  66. package/dist/esm/middleware/body-limit.js.map +1 -1
  67. package/dist/esm/middleware/compress.js +1 -1
  68. package/dist/esm/middleware/compress.js.map +1 -1
  69. package/dist/esm/middleware/cors.js +1 -1
  70. package/dist/esm/middleware/cors.js.map +1 -1
  71. package/dist/esm/middleware/csrf.js +1 -1
  72. package/dist/esm/middleware/csrf.js.map +1 -1
  73. package/dist/esm/middleware/etag.js +1 -1
  74. package/dist/esm/middleware/etag.js.map +1 -1
  75. package/dist/esm/middleware/jwk.d.ts +4 -5
  76. package/dist/esm/middleware/jwk.js +11 -4
  77. package/dist/esm/middleware/jwk.js.map +1 -1
  78. package/dist/esm/middleware/jwt.d.ts +7 -5
  79. package/dist/esm/middleware/jwt.js +11 -5
  80. package/dist/esm/middleware/jwt.js.map +1 -1
  81. package/dist/esm/middleware/secure-headers.js +1 -1
  82. package/dist/esm/middleware/secure-headers.js.map +1 -1
  83. package/dist/esm/middleware/timing.js +1 -1
  84. package/dist/esm/middleware/timing.js.map +1 -1
  85. package/dist/esm/middleware/wrap-hono.d.ts +3 -0
  86. package/dist/esm/middleware/wrap-hono.js +9 -0
  87. package/dist/esm/middleware/wrap-hono.js.map +1 -0
  88. package/dist/esm/middleware.js.map +1 -1
  89. package/dist/esm/reply.d.ts +2 -0
  90. package/dist/esm/reply.js +2 -0
  91. package/dist/esm/route.d.ts +1 -1
  92. package/dist/esm/route.js.map +1 -1
  93. package/dist/esm/stream.d.ts +1 -0
  94. package/dist/esm/stream.js +2 -0
  95. package/dist/esm/taser-app.d.ts +0 -3
  96. package/dist/esm/taser-app.js +1 -6
  97. package/dist/esm/taser-app.js.map +1 -1
  98. package/dist/esm/taser-router.d.ts +9 -11
  99. package/dist/esm/taser-router.js +7 -8
  100. package/dist/esm/taser-router.js.map +1 -1
  101. package/dist/esm/types/app.d.ts +3 -2
  102. package/dist/esm/types/index.d.ts +53 -139
  103. package/dist/esm/types/type-utils.d.ts +8 -11
  104. package/dist/esm/types/units.d.ts +27 -24
  105. package/dist/esm/types/units.js.map +1 -1
  106. package/package.json +37 -17
  107. package/src/constants.ts +6 -6
  108. package/src/create-context.ts +8 -8
  109. package/src/define/handler.ts +24 -34
  110. package/src/define/middleware.ts +66 -256
  111. package/src/define/validators.ts +10 -10
  112. package/src/factories.ts +63 -61
  113. package/src/index.ts +13 -12
  114. package/src/middleware/body-limit.ts +5 -5
  115. package/src/middleware/compress.ts +5 -5
  116. package/src/middleware/cors.ts +5 -5
  117. package/src/middleware/csrf.ts +5 -5
  118. package/src/middleware/etag.ts +5 -5
  119. package/src/middleware/jwk.ts +33 -26
  120. package/src/middleware/jwt.ts +26 -10
  121. package/src/middleware/secure-headers.ts +5 -5
  122. package/src/middleware/timing.ts +5 -5
  123. package/src/middleware/wrap-hono.ts +12 -0
  124. package/src/middleware.ts +7 -7
  125. package/src/reply.ts +11 -0
  126. package/src/route.ts +45 -48
  127. package/src/stream.ts +1 -0
  128. package/src/taser-app.ts +13 -18
  129. package/src/taser-router.ts +103 -98
  130. package/src/types/app.ts +33 -35
  131. package/src/types/index.ts +299 -722
  132. package/src/types/returns.ts +92 -97
  133. package/src/types/schema.ts +8 -9
  134. package/src/types/type-utils.ts +42 -46
  135. package/src/types/units.ts +135 -104
  136. package/dist/cjs/middleware/auth.cjs +0 -34
  137. package/dist/cjs/middleware/auth.cjs.map +0 -1
  138. package/dist/cjs/middleware/auth.d.cts +0 -9
  139. package/dist/esm/middleware/auth.d.ts +0 -9
  140. package/dist/esm/middleware/auth.js +0 -33
  141. package/dist/esm/middleware/auth.js.map +0 -1
  142. package/src/middleware/auth.ts +0 -51
@@ -1,289 +1,99 @@
1
- import type { ReplyResult } from '@taserjs/router-utils'
2
- import { createTaserCompatHandler } from '@taserjs/router-core'
1
+ import { createTaserCompatHandler, type Awaitable } from "@taserjs/router-core";
3
2
 
4
- import type { Awaitable, ReturnsMap } from '../types/index.js'
3
+ import type { ReturnsMap } from "../types/returns.js";
5
4
  import type {
6
5
  AppContext,
6
+ ExtractState,
7
+ IsUnknown,
7
8
  MiddlewareReturnFromParts,
8
9
  MiddlewareUnit,
10
+ NextFn,
9
11
  StandaloneMiddlewareContext,
10
- } from '../types/units.js'
11
- import type { Schema } from '../types/schema.js'
12
+ } from "../types/units.js";
13
+ import type { Schema } from "../types/schema.js";
12
14
 
13
- type HonoMiddlewareHandler = Parameters<typeof createTaserCompatHandler>[0]
15
+ type HonoMiddlewareHandler = Parameters<typeof createTaserCompatHandler>[0];
14
16
 
15
- type HonoMiddlewareUnit = MiddlewareUnit<
16
- MiddlewareReturnFromParts<unknown, unknown, unknown, {}>
17
- >
17
+ type HonoMiddlewareUnit = MiddlewareUnit<MiddlewareReturnFromParts<unknown, unknown, unknown, {}>>;
18
18
 
19
- type MiddlewareBuilderState<
20
- TQuery = unknown,
21
- TParams = unknown,
22
- TBody = unknown,
19
+ export type DefineMiddlewareOptions<
23
20
  TState = unknown,
24
- TCtx = unknown,
25
- TReturns extends ReturnsMap = {},
26
- > = {
27
- state?: Schema<TState>
28
- ctx?: Schema<TCtx>
29
- query?: Schema<TQuery>
30
- params?: Schema<TParams>
31
- body?: Schema<TBody>
32
- returns?: TReturns
33
- }
34
-
35
- type FluentNext<TState, TCtx>
36
- = [TState] extends [undefined]
37
- ? [TCtx] extends [undefined]
38
- ? () => Promise<ReplyResult>
39
- : (args: { ctx: TCtx }) => Promise<ReplyResult>
40
- : [TCtx] extends [undefined]
41
- ? (args: { state: TState }) => Promise<ReplyResult>
42
- : (args: { state: TState, ctx: TCtx }) => Promise<ReplyResult>
43
-
44
- type FluentMiddlewareBuilder<
45
21
  TQuery = unknown,
46
22
  TParams = unknown,
47
23
  TBody = unknown,
48
- TState = undefined,
49
- TCtx = undefined,
50
24
  TReturns extends ReturnsMap = {},
25
+ TQueryIn = unknown,
26
+ TParamsIn = unknown,
27
+ TBodyIn = unknown,
51
28
  TAppContext extends Record<string, unknown> = AppContext,
29
+ R = unknown,
52
30
  > = {
53
- returns<const M extends ReturnsMap>(
54
- map: M,
55
- ): FluentMiddlewareBuilder<
56
- TQuery,
57
- TParams,
58
- TBody,
59
- TState,
60
- TCtx,
61
- Omit<TReturns, keyof M> & M,
62
- TAppContext
63
- >
64
- handler(
65
- fn: (
66
- ctx: StandaloneMiddlewareContext<TQuery, TParams, TBody, TAppContext>,
67
- next: FluentNext<TState, TCtx>,
68
- ) => Awaitable<ReplyResult | Response | unknown>,
69
- ): MiddlewareUnit<
70
- MiddlewareReturnFromParts<
71
- TQuery,
72
- TParams,
73
- TBody,
74
- TState extends undefined ? {} : TState,
75
- TCtx extends undefined ? {} : TCtx
76
- >,
77
- TReturns
78
- >
79
- }
80
-
81
- function createFluentBuilder<TAppContext extends Record<string, unknown> = AppContext>(
82
- state: MiddlewareBuilderState,
83
- ): FluentMiddlewareBuilder<unknown, unknown, unknown, undefined, undefined, {}, TAppContext> {
84
- return {
85
- returns(map: ReturnsMap) {
86
- return createFluentBuilder<TAppContext>({
87
- ...state,
88
- returns: { ...(state.returns ?? {}), ...map },
89
- })
90
- },
91
- handler(fn: (...args: never[]) => unknown) {
92
- const unit = {
93
- ...state,
94
- handler: fn,
95
- __middlewareAcc: undefined as unknown,
96
- ...(state.returns ? { __returns: state.returns } : {}),
97
- }
98
- return unit as unknown as MiddlewareUnit<
99
- MiddlewareReturnFromParts<unknown, unknown, unknown, unknown, unknown>,
100
- ReturnsMap
101
- >
102
- },
103
- } as unknown as FluentMiddlewareBuilder<unknown, unknown, unknown, undefined, undefined, {}, TAppContext>
104
- }
105
-
106
- export function defineMiddleware(middleware: HonoMiddlewareHandler): HonoMiddlewareUnit
107
-
108
- export function defineMiddleware<
109
- TAppContext extends Record<string, unknown> = AppContext,
110
- TState = unknown,
111
- TCtx = unknown,
112
- TQuery = unknown,
113
- TParams = unknown,
114
- TBody = unknown,
115
- TReturns extends ReturnsMap = {},
116
- >(
117
- options: {
118
- state: Schema<TState>
119
- ctx: Schema<TCtx>
120
- query?: Schema<TQuery>
121
- params?: Schema<TParams>
122
- body?: Schema<TBody>
123
- returns?: TReturns
124
- handler: (
125
- ctx: StandaloneMiddlewareContext<TQuery, TParams, TBody, TAppContext>,
126
- next: (args: { state: TState, ctx: TCtx }) => Promise<ReplyResult>,
127
- ) => Awaitable<ReplyResult | Response | unknown>
128
- },
129
- ): MiddlewareUnit<
130
- MiddlewareReturnFromParts<TQuery, TParams, TBody, TState, TCtx>,
131
- TReturns
132
- >
31
+ query?: Schema<TQuery, TQueryIn>;
32
+ params?: Schema<TParams, TParamsIn>;
33
+ body?: Schema<TBody, TBodyIn>;
34
+ returns?: TReturns;
35
+ handler: (
36
+ ctx: StandaloneMiddlewareContext<TQuery, TParams, TBody, TAppContext>,
37
+ next: NextFn<NoInfer<TState>>,
38
+ ) => Awaitable<R>;
39
+ };
40
+
41
+ export function defineMiddleware(middleware: HonoMiddlewareHandler): HonoMiddlewareUnit;
133
42
 
134
43
  export function defineMiddleware<
135
- TAppContext extends Record<string, unknown> = AppContext,
136
44
  TState = unknown,
137
- TQuery = unknown,
138
- TParams = unknown,
139
- TBody = unknown,
140
- TReturns extends ReturnsMap = {},
141
- >(
142
- options: {
143
- state: Schema<TState>
144
- query?: Schema<TQuery>
145
- params?: Schema<TParams>
146
- body?: Schema<TBody>
147
- returns?: TReturns
148
- handler: (
149
- ctx: StandaloneMiddlewareContext<TQuery, TParams, TBody, TAppContext>,
150
- next: (args: { state: TState }) => Promise<ReplyResult>,
151
- ) => Awaitable<ReplyResult | Response | unknown>
152
- },
153
- ): MiddlewareUnit<
154
- MiddlewareReturnFromParts<TQuery, TParams, TBody, TState>,
155
- TReturns
156
- >
157
-
158
- export function defineMiddleware<
159
45
  TAppContext extends Record<string, unknown> = AppContext,
160
- TCtx = unknown,
161
46
  TQuery = unknown,
162
47
  TParams = unknown,
163
48
  TBody = unknown,
164
49
  TReturns extends ReturnsMap = {},
50
+ TQueryIn = unknown,
51
+ TParamsIn = unknown,
52
+ TBodyIn = unknown,
53
+ R = unknown,
165
54
  >(
166
- options: {
167
- ctx: Schema<TCtx>
168
- query?: Schema<TQuery>
169
- params?: Schema<TParams>
170
- body?: Schema<TBody>
171
- returns?: TReturns
172
- handler: (
173
- ctx: StandaloneMiddlewareContext<TQuery, TParams, TBody, TAppContext>,
174
- next: (args: { ctx: TCtx }) => Promise<ReplyResult>,
175
- ) => Awaitable<ReplyResult | Response | unknown>
176
- },
177
- ): MiddlewareUnit<
178
- MiddlewareReturnFromParts<TQuery, TParams, TBody, {}, TCtx>,
179
- TReturns
180
- >
181
-
182
- export function defineMiddleware<
183
- TAppContext extends Record<string, unknown> = AppContext,
184
- TQuery = unknown,
185
- TParams = unknown,
186
- TBody = unknown,
187
- TReturns extends ReturnsMap = {},
188
- >(
189
- options: {
190
- query?: Schema<TQuery>
191
- params?: Schema<TParams>
192
- body?: Schema<TBody>
193
- returns?: TReturns
194
- handler: (
195
- ctx: StandaloneMiddlewareContext<TQuery, TParams, TBody, TAppContext>,
196
- next: () => Promise<ReplyResult>,
197
- ) => Awaitable<ReplyResult | Response | unknown>
198
- },
55
+ options: DefineMiddlewareOptions<
56
+ TState,
57
+ TQuery,
58
+ TParams,
59
+ TBody,
60
+ TReturns,
61
+ TQueryIn,
62
+ TParamsIn,
63
+ TBodyIn,
64
+ TAppContext,
65
+ R
66
+ >,
199
67
  ): MiddlewareUnit<
200
- MiddlewareReturnFromParts<TQuery, TParams, TBody, {}>,
68
+ MiddlewareReturnFromParts<
69
+ TQuery,
70
+ TParams,
71
+ TBody,
72
+ IsUnknown<TState> extends true ? ExtractState<R> : TState,
73
+ TQueryIn,
74
+ TParamsIn,
75
+ TBodyIn
76
+ >,
201
77
  TReturns
202
- >
203
-
204
- export function defineMiddleware<
205
- TAppContext extends Record<string, unknown> = AppContext,
206
- >(): FluentMiddlewareBuilder<unknown, unknown, unknown, undefined, undefined, {}, TAppContext>
207
-
208
- export function defineMiddleware<
209
- TAppContext extends Record<string, unknown> = AppContext,
210
- TQuery = unknown,
211
- TParams = unknown,
212
- TBody = unknown,
213
- >(
214
- options: {
215
- query?: Schema<TQuery>
216
- params?: Schema<TParams>
217
- body?: Schema<TBody>
218
- },
219
- ): FluentMiddlewareBuilder<TQuery, TParams, TBody, undefined, undefined, {}, TAppContext>
220
-
221
- export function defineMiddleware<
222
- TAppContext extends Record<string, unknown> = AppContext,
223
- TState = unknown,
224
- TQuery = unknown,
225
- TParams = unknown,
226
- TBody = unknown,
227
- >(
228
- options: {
229
- state: Schema<TState>
230
- query?: Schema<TQuery>
231
- params?: Schema<TParams>
232
- body?: Schema<TBody>
233
- },
234
- ): FluentMiddlewareBuilder<TQuery, TParams, TBody, TState, undefined, {}, TAppContext>
235
-
236
- export function defineMiddleware<
237
- TAppContext extends Record<string, unknown> = AppContext,
238
- TCtx = unknown,
239
- TQuery = unknown,
240
- TParams = unknown,
241
- TBody = unknown,
242
- >(
243
- options: {
244
- ctx: Schema<TCtx>
245
- query?: Schema<TQuery>
246
- params?: Schema<TParams>
247
- body?: Schema<TBody>
248
- },
249
- ): FluentMiddlewareBuilder<TQuery, TParams, TBody, undefined, TCtx, {}, TAppContext>
250
-
251
- export function defineMiddleware<
252
- TAppContext extends Record<string, unknown> = AppContext,
253
- TState = unknown,
254
- TCtx = unknown,
255
- TQuery = unknown,
256
- TParams = unknown,
257
- TBody = unknown,
258
- >(
259
- options: {
260
- state: Schema<TState>
261
- ctx: Schema<TCtx>
262
- query?: Schema<TQuery>
263
- params?: Schema<TParams>
264
- body?: Schema<TBody>
265
- },
266
- ): FluentMiddlewareBuilder<TQuery, TParams, TBody, TState, TCtx, {}, TAppContext>
267
-
268
- export function defineMiddleware(options?: unknown): unknown {
269
- if (typeof options === 'function') {
270
- const honoMiddleware = options as HonoMiddlewareHandler
78
+ >;
79
+
80
+ export function defineMiddleware(
81
+ options:
82
+ | HonoMiddlewareHandler
83
+ | DefineMiddlewareOptions<any, any, any, any, any, any, any, any, any, any>,
84
+ ): unknown {
85
+ if (typeof options === "function") {
86
+ const honoMiddleware = options as HonoMiddlewareHandler;
271
87
  return defineMiddleware({
272
88
  handler: (ctx, next) => createTaserCompatHandler(honoMiddleware)(ctx, next),
273
- })
89
+ });
274
90
  }
275
91
 
276
- if (options === undefined) {
277
- return createFluentBuilder({})
278
- }
279
-
280
- if (
281
- typeof options === 'object'
282
- && options !== null
283
- && !('handler' in options)
284
- ) {
285
- return createFluentBuilder(options)
286
- }
92
+ const unit = {
93
+ ...options,
94
+ __middlewareAcc: undefined as unknown,
95
+ ...(options.returns ? { __returns: options.returns } : {}),
96
+ };
287
97
 
288
- return options
98
+ return unit;
289
99
  }
@@ -1,22 +1,22 @@
1
- import type { Schema } from '../types/schema.js'
2
- import { SCHEMA_KEYS, type SchemaKey } from '../constants.js'
1
+ import type { Schema } from "../types/schema.js";
2
+ import { SCHEMA_KEYS, type SchemaKey } from "../constants.js";
3
3
 
4
4
  export type SchemaValidators = {
5
- query?: Schema<unknown>
6
- params?: Schema<unknown>
7
- body?: Schema<unknown>
8
- }
5
+ query?: Schema<unknown>;
6
+ params?: Schema<unknown>;
7
+ body?: Schema<unknown>;
8
+ };
9
9
 
10
10
  export function pickDefinedSchemas(
11
11
  source: SchemaValidators,
12
12
  keyMap?: Partial<Record<SchemaKey, string>>,
13
13
  ): Record<string, Schema<unknown>> {
14
- const result: Record<string, Schema<unknown>> = {}
14
+ const result: Record<string, Schema<unknown>> = {};
15
15
  for (const key of SCHEMA_KEYS) {
16
- const value = source[key]
16
+ const value = source[key];
17
17
  if (value !== undefined) {
18
- result[keyMap?.[key] ?? key] = value
18
+ result[keyMap?.[key] ?? key] = value;
19
19
  }
20
20
  }
21
- return result
21
+ return result;
22
22
  }
package/src/factories.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { createRouteBuilder } from './route.js'
2
- import type { RouteBuilder, RoutePath, Schema } from './types/index.js'
3
- import type { AppContext, HttpMethod } from './types/units.js'
1
+ import { createRouteBuilder } from "./route.js";
2
+ import type { RouteBuilder, RoutePath, Schema } from "./types/index.js";
3
+ import type { AppContext, HttpMethod } from "./types/units.js";
4
4
 
5
5
  type WithoutBodyOptions<TQuery, TParams, TQueryIn = unknown, TParamsIn = unknown> = {
6
- query?: Schema<TQuery, TQueryIn>
7
- params?: Schema<TParams, TParamsIn>
8
- }
6
+ query?: Schema<TQuery, TQueryIn>;
7
+ params?: Schema<TParams, TParamsIn>;
8
+ };
9
9
 
10
10
  type WithBodyOptions<
11
11
  TQuery,
@@ -15,14 +15,16 @@ type WithBodyOptions<
15
15
  TParamsIn = unknown,
16
16
  TBodyIn = unknown,
17
17
  > = WithoutBodyOptions<TQuery, TParams, TQueryIn, TParamsIn> & {
18
- body?: Schema<TBody, TBodyIn>
19
- }
18
+ body?: Schema<TBody, TBodyIn>;
19
+ };
20
20
 
21
21
  export type CreateWithoutBodyRoute<
22
- M extends 'GET' | 'DELETE' | 'OPTIONS' | 'HEAD',
22
+ M extends "GET" | "DELETE" | "OPTIONS" | "HEAD",
23
23
  TAppContext extends Record<string, unknown> = AppContext,
24
24
  > = {
25
- <const Path extends RoutePath>(path: Path): RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>
25
+ <const Path extends RoutePath>(
26
+ path: Path,
27
+ ): RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;
26
28
  <
27
29
  const Path extends RoutePath,
28
30
  TQuery = unknown,
@@ -37,21 +39,23 @@ export type CreateWithoutBodyRoute<
37
39
  M,
38
40
  readonly [],
39
41
  {
40
- query: TQuery
41
- params: TParams
42
- queryIn: TQueryIn
43
- paramsIn: TParamsIn
42
+ query: TQuery;
43
+ params: TParams;
44
+ queryIn: TQueryIn;
45
+ paramsIn: TParamsIn;
44
46
  },
45
47
  {},
46
48
  TAppContext
47
- >
48
- }
49
+ >;
50
+ };
49
51
 
50
52
  export type CreateWithBodyRoute<
51
- M extends 'POST' | 'PUT' | 'PATCH',
53
+ M extends "POST" | "PUT" | "PATCH",
52
54
  TAppContext extends Record<string, unknown> = AppContext,
53
55
  > = {
54
- <const Path extends RoutePath>(path: Path): RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>
56
+ <const Path extends RoutePath>(
57
+ path: Path,
58
+ ): RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;
55
59
  <
56
60
  const Path extends RoutePath,
57
61
  TQuery = unknown,
@@ -68,23 +72,23 @@ export type CreateWithBodyRoute<
68
72
  M,
69
73
  readonly [],
70
74
  {
71
- query: TQuery
72
- params: TParams
73
- body: TBody
74
- queryIn: TQueryIn
75
- paramsIn: TParamsIn
76
- bodyIn: TBodyIn
75
+ query: TQuery;
76
+ params: TParams;
77
+ body: TBody;
78
+ queryIn: TQueryIn;
79
+ paramsIn: TParamsIn;
80
+ bodyIn: TBodyIn;
77
81
  },
78
82
  {},
79
83
  TAppContext
80
- >
81
- }
84
+ >;
85
+ };
82
86
 
83
87
  export type CreateAnyRoute<TAppContext extends Record<string, unknown> = AppContext> = {
84
88
  <const Path extends RoutePath, const Methods extends readonly HttpMethod[]>(
85
89
  path: Path,
86
90
  methods: Methods,
87
- ): RouteBuilder<Path, Methods[number], readonly [], {}, {}, TAppContext>
91
+ ): RouteBuilder<Path, Methods[number], readonly [], {}, {}, TAppContext>;
88
92
  <
89
93
  const Path extends RoutePath,
90
94
  const Methods extends readonly HttpMethod[],
@@ -103,20 +107,22 @@ export type CreateAnyRoute<TAppContext extends Record<string, unknown> = AppCont
103
107
  Methods[number],
104
108
  readonly [],
105
109
  {
106
- query: TQuery
107
- params: TParams
108
- body: TBody
109
- queryIn: TQueryIn
110
- paramsIn: TParamsIn
111
- bodyIn: TBodyIn
110
+ query: TQuery;
111
+ params: TParams;
112
+ body: TBody;
113
+ queryIn: TQueryIn;
114
+ paramsIn: TParamsIn;
115
+ bodyIn: TBodyIn;
112
116
  },
113
117
  {},
114
118
  TAppContext
115
- >
116
- }
119
+ >;
120
+ };
117
121
 
118
122
  export type CreateAllRoute<TAppContext extends Record<string, unknown> = AppContext> = {
119
- <const Path extends RoutePath>(path: Path): RouteBuilder<Path, HttpMethod, readonly [], {}, {}, TAppContext>
123
+ <const Path extends RoutePath>(
124
+ path: Path,
125
+ ): RouteBuilder<Path, HttpMethod, readonly [], {}, {}, TAppContext>;
120
126
  <
121
127
  const Path extends RoutePath,
122
128
  TQuery = unknown,
@@ -133,51 +139,47 @@ export type CreateAllRoute<TAppContext extends Record<string, unknown> = AppCont
133
139
  HttpMethod,
134
140
  readonly [],
135
141
  {
136
- query: TQuery
137
- params: TParams
138
- body: TBody
139
- queryIn: TQueryIn
140
- paramsIn: TParamsIn
141
- bodyIn: TBodyIn
142
+ query: TQuery;
143
+ params: TParams;
144
+ body: TBody;
145
+ queryIn: TQueryIn;
146
+ paramsIn: TParamsIn;
147
+ bodyIn: TBodyIn;
142
148
  },
143
149
  {},
144
150
  TAppContext
145
- >
146
- }
151
+ >;
152
+ };
147
153
 
148
- function createWithoutBodyRoute<M extends 'GET' | 'DELETE' | 'OPTIONS' | 'HEAD'>(
154
+ function createWithoutBodyRoute<M extends "GET" | "DELETE" | "OPTIONS" | "HEAD">(
149
155
  method: M,
150
156
  ): CreateWithoutBodyRoute<M> {
151
157
  return ((path: string, options?: WithoutBodyOptions<unknown, unknown>) =>
152
- createRouteBuilder(path, method, options)
153
- ) as unknown as CreateWithoutBodyRoute<M>
158
+ createRouteBuilder(path, method, options)) as unknown as CreateWithoutBodyRoute<M>;
154
159
  }
155
160
 
156
- function createWithBodyRoute<M extends 'POST' | 'PUT' | 'PATCH'>(
161
+ function createWithBodyRoute<M extends "POST" | "PUT" | "PATCH">(
157
162
  method: M,
158
163
  ): CreateWithBodyRoute<M> {
159
164
  return ((path: string, options?: WithBodyOptions<unknown, unknown, unknown>) =>
160
- createRouteBuilder(path, method, options)
161
- ) as unknown as CreateWithBodyRoute<M>
165
+ createRouteBuilder(path, method, options)) as unknown as CreateWithBodyRoute<M>;
162
166
  }
163
167
 
164
- export const createGetRoute = createWithoutBodyRoute('GET')
165
- export const createDeleteRoute = createWithoutBodyRoute('DELETE')
166
- export const createOptionsRoute = createWithoutBodyRoute('OPTIONS')
167
- export const createHeadRoute = createWithoutBodyRoute('HEAD')
168
- export const createPostRoute = createWithBodyRoute('POST')
169
- export const createPutRoute = createWithBodyRoute('PUT')
170
- export const createPatchRoute = createWithBodyRoute('PATCH')
168
+ export const createGetRoute = createWithoutBodyRoute("GET");
169
+ export const createDeleteRoute = createWithoutBodyRoute("DELETE");
170
+ export const createOptionsRoute = createWithoutBodyRoute("OPTIONS");
171
+ export const createHeadRoute = createWithoutBodyRoute("HEAD");
172
+ export const createPostRoute = createWithBodyRoute("POST");
173
+ export const createPutRoute = createWithBodyRoute("PUT");
174
+ export const createPatchRoute = createWithBodyRoute("PATCH");
171
175
 
172
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
173
176
  export const createAnyRoute: CreateAnyRoute = ((
174
177
  path: string,
175
178
  methods: readonly HttpMethod[],
176
179
  options?: WithBodyOptions<unknown, unknown, unknown>,
177
- ) => createRouteBuilder(path, 'ANY', options, methods)) as unknown as CreateAnyRoute
180
+ ) => createRouteBuilder(path, "ANY", options, methods)) as unknown as CreateAnyRoute;
178
181
 
179
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
180
182
  export const createAllRoute: CreateAllRoute = ((
181
183
  path: string,
182
184
  options?: WithBodyOptions<unknown, unknown, unknown>,
183
- ) => createRouteBuilder(path, 'ALL', options)) as unknown as CreateAllRoute
185
+ ) => createRouteBuilder(path, "ALL", options)) as unknown as CreateAllRoute;
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { RouterRegister } from './register.js'
1
+ export type { RouterRegister } from "./register.js";
2
2
  export type {
3
3
  InferInput,
4
4
  InferOutput,
@@ -8,7 +8,7 @@ export type {
8
8
  RoutePath,
9
9
  Schema,
10
10
  Simplify,
11
- } from './types/index.js'
11
+ } from "./types/index.js";
12
12
  export type {
13
13
  ContextDefinition,
14
14
  CreateContextArgs,
@@ -18,27 +18,28 @@ export type {
18
18
  OnErrorOptions,
19
19
  RouteManifestShape,
20
20
  TaserHandler,
21
- } from './types/app.js'
21
+ } from "./types/app.js";
22
22
 
23
23
  export {
24
24
  isReplyResult,
25
25
  reply,
26
+ stream,
26
27
  ValidationError,
27
28
  validationErrorSchema,
28
- } from '@taserjs/router-utils'
29
+ } from "@taserjs/router-utils";
29
30
  export type {
30
31
  ReplyBodyKind,
31
32
  ReplyOf,
32
33
  ResponseValidationFailureHandler,
33
34
  SuccessReplyData,
34
35
  SuccessStatusCode,
35
- } from '@taserjs/router-utils'
36
+ } from "@taserjs/router-utils";
36
37
 
37
- export { createAnyRoute, createAllRoute } from './factories.js'
38
- export { createTaserApp, TaserRouter } from './taser-router.js'
39
- export { TaserApp, TaserMountedApp, TaserNativeBound } from './taser-app.js'
40
- export { createContext } from './create-context.js'
41
- export { defineHandler } from './define/handler.js'
42
- export { defineMiddleware } from './define/middleware.js'
38
+ export { createAnyRoute, createAllRoute } from "./factories.js";
39
+ export { createTaserApp, TaserRouter } from "./taser-router.js";
40
+ export { TaserApp, TaserNativeBound } from "./taser-app.js";
41
+ export { createContext } from "./create-context.js";
42
+ export { defineHandler } from "./define/handler.js";
43
+ export { defineMiddleware } from "./define/middleware.js";
43
44
 
44
- export type { TaserCookieJar, TaserHeaders } from '@taserjs/router-core'
45
+ export type { TaserCookieJar, TaserHeaders } from "@taserjs/router-core";
@@ -1,11 +1,11 @@
1
- import { bodyLimit as honoBodyLimit } from 'hono/body-limit'
1
+ import { bodyLimit as honoBodyLimit } from "hono/body-limit";
2
2
 
3
- import { wrapHonoMiddleware } from './auth.js'
3
+ import { wrapHonoMiddleware } from "./wrap-hono.js";
4
4
 
5
- const honoBodyLimitMiddleware = wrapHonoMiddleware(honoBodyLimit)
5
+ const honoBodyLimitMiddleware = wrapHonoMiddleware(honoBodyLimit);
6
6
 
7
7
  export function bodyLimit(...args: Parameters<typeof honoBodyLimit>) {
8
- return honoBodyLimitMiddleware(...args)
8
+ return honoBodyLimitMiddleware(...args);
9
9
  }
10
10
 
11
- export type BodyLimitOptions = Parameters<typeof honoBodyLimit>[0]
11
+ export type BodyLimitOptions = Parameters<typeof honoBodyLimit>[0];