@athenna/http 1.3.3 → 1.3.4

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 (95) hide show
  1. package/LICENSE.md +3 -15
  2. package/README.md +8 -5
  3. package/package.json +95 -106
  4. package/src/Context/Request.js +168 -137
  5. package/src/Context/Response.js +102 -94
  6. package/src/Exceptions/UndefinedMethodException.js +30 -0
  7. package/src/Facades/Route.js +7 -5
  8. package/src/Facades/Server.js +7 -5
  9. package/src/Handlers/FastifyHandler.js +134 -115
  10. package/src/Handlers/HttpExceptionHandler.js +71 -68
  11. package/src/Kernels/HttpKernel.js +142 -124
  12. package/src/Providers/ControllerProvider.js +30 -39
  13. package/src/Providers/HttpRouteProvider.js +15 -16
  14. package/src/Providers/HttpServerProvider.js +13 -15
  15. package/src/Providers/MiddlewareProvider.js +30 -39
  16. package/src/Router/Route.js +192 -99
  17. package/src/Router/RouteGroup.js +66 -40
  18. package/src/Router/RouteResource.js +156 -74
  19. package/src/Router/Router.js +284 -112
  20. package/src/Utils/isMiddlewareContract.js +8 -6
  21. package/src/Utils/removeSlashes.js +21 -0
  22. package/src/index.d.ts +658 -0
  23. package/src/index.js +284 -0
  24. package/index.d.ts +0 -29
  25. package/index.js +0 -41
  26. package/src/Context/Request.d.ts +0 -103
  27. package/src/Context/Response.d.ts +0 -77
  28. package/src/Contracts/Context/ContextContract.d.ts +0 -17
  29. package/src/Contracts/Context/ContextContract.js +0 -10
  30. package/src/Contracts/Context/Error/ErrorContextContract.d.ts +0 -18
  31. package/src/Contracts/Context/Error/ErrorContextContract.js +0 -10
  32. package/src/Contracts/Context/Error/ErrorHandlerContract.d.ts +0 -12
  33. package/src/Contracts/Context/Error/ErrorHandlerContract.js +0 -10
  34. package/src/Contracts/Context/HandlerContract.d.ts +0 -12
  35. package/src/Contracts/Context/HandlerContract.js +0 -10
  36. package/src/Contracts/Context/Middlewares/Handle/HandleContextContract.d.ts +0 -19
  37. package/src/Contracts/Context/Middlewares/Handle/HandleContextContract.js +0 -10
  38. package/src/Contracts/Context/Middlewares/Handle/HandleHandlerContract.d.ts +0 -12
  39. package/src/Contracts/Context/Middlewares/Handle/HandleHandlerContract.js +0 -10
  40. package/src/Contracts/Context/Middlewares/Intercept/InterceptContextContract.d.ts +0 -19
  41. package/src/Contracts/Context/Middlewares/Intercept/InterceptContextContract.js +0 -10
  42. package/src/Contracts/Context/Middlewares/Intercept/InterceptHandlerContract.d.ts +0 -12
  43. package/src/Contracts/Context/Middlewares/Intercept/InterceptHandlerContract.js +0 -10
  44. package/src/Contracts/Context/Middlewares/Terminate/TerminateContextContract.d.ts +0 -23
  45. package/src/Contracts/Context/Middlewares/Terminate/TerminateContextContract.js +0 -10
  46. package/src/Contracts/Context/Middlewares/Terminate/TerminateHandlerContract.d.ts +0 -12
  47. package/src/Contracts/Context/Middlewares/Terminate/TerminateHandlerContract.js +0 -10
  48. package/src/Contracts/Context/NextContract.d.ts +0 -11
  49. package/src/Contracts/Context/NextContract.js +0 -10
  50. package/src/Contracts/Context/RequestContract.d.ts +0 -25
  51. package/src/Contracts/Context/RequestContract.js +0 -10
  52. package/src/Contracts/Context/ResponseContract.d.ts +0 -20
  53. package/src/Contracts/Context/ResponseContract.js +0 -2
  54. package/src/Contracts/FastifyErrorHandlerContract.d.ts +0 -12
  55. package/src/Contracts/FastifyErrorHandlerContract.js +0 -10
  56. package/src/Contracts/FastifyHandlerContract.d.ts +0 -12
  57. package/src/Contracts/FastifyHandlerContract.js +0 -10
  58. package/src/Contracts/HttpMethodTypes.d.ts +0 -9
  59. package/src/Contracts/HttpMethodTypes.js +0 -10
  60. package/src/Contracts/MiddlewareContract.d.ts +0 -16
  61. package/src/Contracts/MiddlewareContract.js +0 -10
  62. package/src/Contracts/MiddlewareTypes.d.ts +0 -9
  63. package/src/Contracts/MiddlewareTypes.js +0 -10
  64. package/src/Contracts/MiddlewareTypesContract.d.ts +0 -16
  65. package/src/Contracts/MiddlewareTypesContract.js +0 -10
  66. package/src/Contracts/RouteContract.d.ts +0 -16
  67. package/src/Contracts/RouteContract.js +0 -10
  68. package/src/Exceptions/BadRequestException.d.ts +0 -12
  69. package/src/Exceptions/BadRequestException.js +0 -18
  70. package/src/Exceptions/CannotDefineGroupException.d.ts +0 -12
  71. package/src/Exceptions/CannotDefineGroupException.js +0 -19
  72. package/src/Exceptions/MiddlewareNotFoundException.d.ts +0 -12
  73. package/src/Exceptions/MiddlewareNotFoundException.js +0 -19
  74. package/src/Exceptions/UndefinedControllerMethodException.d.ts +0 -12
  75. package/src/Exceptions/UndefinedControllerMethodException.js +0 -19
  76. package/src/Facades/Route.d.ts +0 -10
  77. package/src/Facades/Server.d.ts +0 -10
  78. package/src/Handlers/FastifyHandler.d.ts +0 -26
  79. package/src/Handlers/HttpExceptionHandler.d.ts +0 -27
  80. package/src/Http.d.ts +0 -167
  81. package/src/Http.js +0 -223
  82. package/src/Kernels/HttpKernel.d.ts +0 -54
  83. package/src/Providers/ControllerProvider.d.ts +0 -17
  84. package/src/Providers/HttpRouteProvider.d.ts +0 -17
  85. package/src/Providers/HttpServerProvider.d.ts +0 -17
  86. package/src/Providers/MiddlewareProvider.d.ts +0 -17
  87. package/src/Router/Route.d.ts +0 -32
  88. package/src/Router/RouteGroup.d.ts +0 -24
  89. package/src/Router/RouteResource.d.ts +0 -29
  90. package/src/Router/Router.d.ts +0 -39
  91. package/src/Utils/getAppFiles.d.ts +0 -10
  92. package/src/Utils/getAppFiles.js +0 -22
  93. package/src/Utils/isMiddlewareContract.d.ts +0 -10
  94. package/src/Utils/removeSlash.d.ts +0 -9
  95. package/src/Utils/removeSlash.js +0 -23
package/src/index.d.ts ADDED
@@ -0,0 +1,658 @@
1
+ /**
2
+ * @athenna/http
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
10
+ import { Facade } from '@athenna/ioc'
11
+ import { FastifyReply, FastifyRequest } from 'fastify'
12
+
13
+ export const Server: Facade & Http
14
+ export const Route: Facade & Router.Router
15
+
16
+ export class HttpKernel {
17
+ /**
18
+ * The application's global HTTP middlewares.
19
+ *
20
+ * This middlewares are run during every request to your http server.
21
+ *
22
+ * @type {any | Promise<any>}
23
+ */
24
+ globalMiddlewares: any | Promise<any>
25
+ /**
26
+ * The application's named HTTP middlewares.
27
+ *
28
+ * Here you define all your named middlewares to use inside routes/http file.
29
+ *
30
+ * @type {Record<string, any | Promise<any>>}
31
+ */
32
+ namedMiddlewares: Record<string, any | Promise<any>>
33
+
34
+ /**
35
+ * Register all global and named middlewares to the server.
36
+ *
37
+ * @return void
38
+ */
39
+ registerMiddlewares(): Promise<void>
40
+
41
+ /**
42
+ * Register cors plugin.
43
+ *
44
+ * @return {Promise<void>}
45
+ */
46
+ registerCors(): Promise<void>
47
+
48
+ /**
49
+ * Register rate limit plugin.
50
+ *
51
+ * @return {Promise<void>}
52
+ */
53
+ registerRateLimit(): Promise<void>
54
+
55
+ /**
56
+ * Register the default error handler.
57
+ *
58
+ * @return {Promise<void>}
59
+ */
60
+ registerErrorHandler(): Promise<void>
61
+
62
+ /**
63
+ * Register log terminate middleware.
64
+ *
65
+ * @return {Promise<void>}
66
+ */
67
+ registerLogMiddleware(): Promise<void>
68
+
69
+ /**
70
+ * Register the requestId handle middleware.
71
+ *
72
+ * @return {Promise<void>}
73
+ */
74
+ registerRequestIdMiddleware(): Promise<void>
75
+ }
76
+
77
+ export class HttpExceptionHandler {
78
+ /**
79
+ * Error codes that should be ignored by Log.
80
+ *
81
+ * @type {string[]}
82
+ */
83
+ ignoreCodes: string[]
84
+ /**
85
+ * Error statuses that should be ignored by Log.
86
+ *
87
+ * @type {number[]}
88
+ */
89
+ ignoreStatuses: number[]
90
+
91
+ /**
92
+ * The global exception handler of all HTTP requests.
93
+ *
94
+ * @param ctx
95
+ */
96
+ handle({ error, response }: { error: any; response: any }): Promise<any>
97
+ }
98
+
99
+ export class Http {
100
+ /**
101
+ * Set the fastify error handler.
102
+ *
103
+ * @param {any} handler
104
+ * @return {Http}
105
+ */
106
+ setErrorHandler(handler: any): Http
107
+
108
+ /**
109
+ * Register a new fastify plugin.
110
+ *
111
+ * @param {import('fastify').FastifyPluginCallback<import('fastify').FastifyPluginOptions>} plugin
112
+ * @param {import('fastify').FastifyRegisterOptions<import('fastify').FastifyPluginOptions>} [options]
113
+ * @return {Http}
114
+ */
115
+ register(
116
+ plugin: import('fastify').FastifyPluginCallback<
117
+ import('fastify').FastifyPluginOptions
118
+ >,
119
+ options?: import('fastify').FastifyRegisterOptions<
120
+ import('fastify').FastifyPluginOptions
121
+ >,
122
+ ): Http
123
+
124
+ /**
125
+ * Register the cors plugin to fastify server.
126
+ *
127
+ * @param {import('fastify-cors').FastifyCorsOptions} [options]
128
+ * @return {Http}
129
+ */
130
+ registerCors(options?: import('fastify-cors').FastifyCorsOptions): Http
131
+
132
+ /**
133
+ * Register the rate limit plugin to fastify server.
134
+ *
135
+ * @param {import('fastify-rate-limit').RateLimitPluginOptions} [options]
136
+ * @return {Http}
137
+ */
138
+ registerRateLimit(
139
+ options?: import('fastify-rate-limit').RateLimitPluginOptions,
140
+ ): Http
141
+
142
+ /**
143
+ * Get the fastify server instance.
144
+ *
145
+ * @return {import('fastify').FastifyInstance}
146
+ */
147
+ getFastify(): import('fastify').FastifyInstance
148
+
149
+ /**
150
+ * Print all routes registered.
151
+ *
152
+ * @param {import('fastify').PrintRoutesOptions} [options]
153
+ * @return {string}
154
+ */
155
+ getRoutes(options?: import('fastify').PrintRoutesOptions): string
156
+
157
+ /**
158
+ * Print all routes registered.
159
+ *
160
+ * @param {any} handler
161
+ * @param {'handle'|'intercept'|'terminate'} type
162
+ * @return void
163
+ */
164
+ use(handler: any, type?: 'handle' | 'intercept' | 'terminate'): void
165
+
166
+ /**
167
+ * Return a request handler to make internal requests to the Http server.
168
+ *
169
+ * @param {import('fastify').InjectOptions|string} [options]
170
+ * @return {import('light-my-request').Chain,Promise<import('light-my-request').Response>}
171
+ */
172
+ request(
173
+ options?: import('fastify').InjectOptions | string,
174
+ ): import('light-my-request').Chain
175
+
176
+ /**
177
+ * Boot the http server to start listening on port and host defined.
178
+ *
179
+ * @param {string|number} [port]
180
+ * @param {string} [host]
181
+ * @return {Promise<string>}
182
+ */
183
+ listen(port?: string | number, host?: string): Promise<string>
184
+
185
+ /**
186
+ * Close the http server.
187
+ *
188
+ * @return {Promise<void>}
189
+ */
190
+ close(): Promise<void>
191
+
192
+ /**
193
+ * Add a new route to the http server.
194
+ *
195
+ * @param {string} url
196
+ * @param {string[]} methods
197
+ * @param {any} handler
198
+ * @param {any} [middlewares]
199
+ * @return {void}
200
+ */
201
+ route(url: string, methods: string[], handler: any, middlewares?: any): void
202
+
203
+ /**
204
+ * Add a new GET route to the http server.
205
+ *
206
+ * @param {string} url
207
+ * @param {any} handler
208
+ * @param {any} [middlewares]
209
+ * @return {void}
210
+ */
211
+ get(url: string, handler: any, middlewares?: any): void
212
+
213
+ /**
214
+ * Add a new HEAD route to the http server.
215
+ *
216
+ * @param {string} url
217
+ * @param {any} handler
218
+ * @param {any} [middlewares]
219
+ * @return {void}
220
+ */
221
+ head(url: string, handler: any, middlewares?: any): void
222
+
223
+ /**
224
+ * Add a new POST route to the http server.
225
+ *
226
+ * @param {string} url
227
+ * @param {any} handler
228
+ * @param {any} [middlewares]
229
+ * @return {void}
230
+ */
231
+ post(url: string, handler: any, middlewares?: any): void
232
+
233
+ /**
234
+ * Add a new PUT route to the http server.
235
+ *
236
+ * @param {string} url
237
+ * @param {any} handler
238
+ * @param {any} [middlewares]
239
+ * @return {void}
240
+ */
241
+ put(url: string, handler: any, middlewares?: any): void
242
+
243
+ /**
244
+ * Add a new PATCH route to the http server.
245
+ *
246
+ * @param {string} url
247
+ * @param {any} handler
248
+ * @param {any} [middlewares]
249
+ * @return {void}
250
+ */
251
+ patch(url: string, handler: any, middlewares?: any): void
252
+
253
+ /**
254
+ * Add a new DELETE route to the http server.
255
+ *
256
+ * @param {string} url
257
+ * @param {any} handler
258
+ * @param {any} [middlewares]
259
+ * @return {void}
260
+ */
261
+ delete(url: string, handler: any, middlewares?: any): void
262
+
263
+ /**
264
+ * Add a new OPTIONS route to the http server.
265
+ *
266
+ * @param {string} url
267
+ * @param {any} handler
268
+ * @param {any} [middlewares]
269
+ * @return {void}
270
+ */
271
+ options(url: string, handler: any, middlewares?: any): void
272
+ }
273
+
274
+ declare module Router {
275
+ class Route {
276
+ name: string
277
+ deleted: boolean
278
+
279
+ constructor(
280
+ url: string,
281
+ methods: string[],
282
+ handler: HandlerContract | string,
283
+ )
284
+
285
+ prefix(prefix): this
286
+
287
+ middleware(
288
+ middleware: string,
289
+ type?: 'handle' | 'intercept' | 'terminate',
290
+ prepend?: boolean,
291
+ ): this
292
+
293
+ middleware(
294
+ middleware: MiddlewareContract,
295
+ type?: 'handle' | 'intercept' | 'terminate',
296
+ prepend?: boolean,
297
+ ): this
298
+
299
+ middleware(
300
+ middleware: HandleHandlerContract,
301
+ type?: 'handle',
302
+ prepend?: boolean,
303
+ ): this
304
+
305
+ middleware(
306
+ middleware: InterceptHandlerContract,
307
+ type?: 'intercept',
308
+ prepend?: boolean,
309
+ ): this
310
+
311
+ middleware(
312
+ middleware: TerminateHandlerContract,
313
+ type?: 'terminate',
314
+ prepend?: boolean,
315
+ ): this
316
+
317
+ toJSON(): any
318
+ }
319
+
320
+ export class RouteResource {
321
+ routes: Route[]
322
+
323
+ constructor(resource: string, controller: any)
324
+
325
+ middleware(
326
+ middleware: string,
327
+ type?: 'handle' | 'intercept' | 'terminate',
328
+ prepend?: boolean,
329
+ ): this
330
+
331
+ middleware(
332
+ middleware: MiddlewareContract,
333
+ type?: 'handle' | 'intercept' | 'terminate',
334
+ prepend?: boolean,
335
+ ): this
336
+
337
+ middleware(
338
+ middleware: HandleHandlerContract,
339
+ type?: 'handle',
340
+ prepend?: boolean,
341
+ ): this
342
+
343
+ middleware(
344
+ middleware: InterceptHandlerContract,
345
+ type?: 'intercept',
346
+ prepend?: boolean,
347
+ ): this
348
+
349
+ middleware(
350
+ middleware: TerminateHandlerContract,
351
+ type?: 'terminate',
352
+ prepend?: boolean,
353
+ ): this
354
+
355
+ only(names: string[]): this
356
+
357
+ except(names: string[]): this
358
+ }
359
+
360
+ export class RouteGroup {
361
+ routes: (Route | RouteResource | RouteGroup)[]
362
+
363
+ constructor(routes: (Route | RouteResource | RouteGroup)[])
364
+
365
+ prefix(prefix: string): this
366
+
367
+ middleware(
368
+ middleware: string,
369
+ type?: 'handle' | 'intercept' | 'terminate',
370
+ prepend?: boolean,
371
+ ): this
372
+
373
+ middleware(
374
+ middleware: MiddlewareContract,
375
+ type?: 'handle' | 'intercept' | 'terminate',
376
+ prepend?: boolean,
377
+ ): this
378
+
379
+ middleware(
380
+ middleware: HandleHandlerContract,
381
+ type?: 'handle',
382
+ prepend?: boolean,
383
+ ): this
384
+
385
+ middleware(
386
+ middleware: InterceptHandlerContract,
387
+ type?: 'intercept',
388
+ prepend?: boolean,
389
+ ): this
390
+
391
+ middleware(
392
+ middleware: TerminateHandlerContract,
393
+ type?: 'terminate',
394
+ prepend?: boolean,
395
+ ): this
396
+ }
397
+
398
+ export class Router {
399
+ /**
400
+ * List the routes registered.
401
+ *
402
+ * @return {any}
403
+ */
404
+ listRoutes(): any
405
+
406
+ /**
407
+ * Set the controller instance.
408
+ *
409
+ * @param {any} controller
410
+ * @return {Router}
411
+ */
412
+ controller(controller: any): Router
413
+
414
+ /**
415
+ * Register a new route.
416
+ *
417
+ * @param {string} url
418
+ * @param {string[]} methods
419
+ * @param {string|any} handler
420
+ * @return {Route}
421
+ */
422
+ route(url: string, methods: string[], handler: string | any): Route
423
+
424
+ /**
425
+ * Creates a new route group.
426
+ *
427
+ * @param {() => void} callback
428
+ * @return {RouteGroup}
429
+ */
430
+ group(callback: () => void): RouteGroup
431
+
432
+ /**
433
+ * Creates a new route resource.
434
+ *
435
+ * @param {string} resource
436
+ * @param {any} controller
437
+ * @return {RouteResource}
438
+ */
439
+ resource(resource: string, controller: any): RouteResource
440
+
441
+ /**
442
+ * Creates a new redirect route.
443
+ *
444
+ * @param {string} url
445
+ * @param {string} redirectTo
446
+ * @param {number} [status]
447
+ * @return {Route}
448
+ */
449
+ redirect(url: string, redirectTo: string, status?: number): Route
450
+
451
+ /**
452
+ * Register a new get method route.
453
+ *
454
+ * @param {string} url
455
+ * @param {string|any} handler
456
+ * @return {Route}
457
+ */
458
+ get(url: string, handler: string | any): Route
459
+
460
+ /**
461
+ * Register a new head method route.
462
+ *
463
+ * @param {string} url
464
+ * @param {string|any} handler
465
+ * @return {Route}
466
+ */
467
+ head(url: string, handler: string | any): Route
468
+
469
+ /**
470
+ * Register a new post method route.
471
+ *
472
+ * @param {string} url
473
+ * @param {string|any} handler
474
+ * @return {Route}
475
+ */
476
+ post(url: string, handler: string | any): Route
477
+
478
+ /**
479
+ * Register a new put method route.
480
+ *
481
+ * @param {string} url
482
+ * @param {string|any} handler
483
+ * @return {Route}
484
+ */
485
+ put(url: string, handler: string | any): Route
486
+
487
+ /**
488
+ * Register a new patch method route.
489
+ *
490
+ * @param {string} url
491
+ * @param {string|any} handler
492
+ * @return {Route}
493
+ */
494
+ patch(url: string, handler: string | any): Route
495
+
496
+ /**
497
+ * Register a new delete method route.
498
+ *
499
+ * @param {string} url
500
+ * @param {string|any} handler
501
+ * @return {Route}
502
+ */
503
+ delete(url: string, handler: string | any): Route
504
+
505
+ /**
506
+ * Register a new options method route.
507
+ *
508
+ * @param {string} url
509
+ * @param {string|any} handler
510
+ * @return {Route}
511
+ */
512
+ options(url: string, handler: string | any): Route
513
+
514
+ /**
515
+ * Register a new route with all methods.
516
+ *
517
+ * @param {string} url
518
+ * @param {string|any} handler
519
+ * @return {Route}
520
+ */
521
+ any(url: string, handler: string | any): Route
522
+
523
+ /**
524
+ * Register all the routes inside the Server.
525
+ *
526
+ * @return {Route}
527
+ */
528
+ register(): Route
529
+
530
+ /**
531
+ * Transform the routes to JSON Object.
532
+ *
533
+ * @param {any[]} [routes]
534
+ */
535
+ toRoutesJSON(routes?: any[]): any
536
+ }
537
+ }
538
+
539
+ export interface RequestContract {
540
+ ip: string
541
+ method: string
542
+ hostUrl: string
543
+ baseUrl: string
544
+ originalUrl: string
545
+ body: any
546
+ params: any
547
+ queries: any
548
+ headers: any
549
+
550
+ param(param: string, defaultValue?: string): string | undefined
551
+
552
+ query(query: string, defaultValue?: string): string | undefined
553
+
554
+ header(header: string, defaultValue?: string): string | string[] | undefined
555
+
556
+ payload(payload: string, defaultValue?: string): any | undefined
557
+
558
+ getFastifyRequest(): FastifyRequest
559
+ }
560
+
561
+ export interface ResponseContract {
562
+ send(data?: any): Promise<void> | void
563
+
564
+ json(data?: any): Promise<void> | void
565
+
566
+ status(code: number): this
567
+
568
+ removeHeader(header: string): this
569
+
570
+ header(header: string, value: any): this
571
+
572
+ safeHeader(header: string, value: any): this
573
+
574
+ redirectTo(url: string): Promise<void> | void
575
+
576
+ redirectTo(url: string, statusCode: number): Promise<void> | void
577
+
578
+ getFastifyResponse(): FastifyReply
579
+ }
580
+
581
+ export interface NextContract {
582
+ (...params: any[]): void
583
+ }
584
+
585
+ export interface ContextContract {
586
+ request: RequestContract
587
+ response: ResponseContract
588
+ data: any
589
+ params: any
590
+ queries: any
591
+ }
592
+
593
+ export interface ErrorContextContract {
594
+ request: RequestContract
595
+ response: ResponseContract
596
+ params: any
597
+ queries: any
598
+ data: any
599
+ error: any
600
+ }
601
+
602
+ export interface HandleContextContract {
603
+ request: RequestContract
604
+ response: ResponseContract
605
+ data: any
606
+ params: any
607
+ queries: any
608
+ next: NextContract
609
+ }
610
+
611
+ export interface InterceptContextContract {
612
+ request: RequestContract
613
+ response: ResponseContract
614
+ params: any
615
+ queries: any
616
+ body: any
617
+ status: number
618
+ data: any
619
+ }
620
+
621
+ export interface TerminateContextContract {
622
+ request: RequestContract
623
+ response: ResponseContract
624
+ data: any
625
+ params: any
626
+ queries: any
627
+ body: any
628
+ headers: any
629
+ status: number
630
+ responseTime: number
631
+ next: NextContract
632
+ }
633
+
634
+ export interface ErrorHandlerContract {
635
+ (ctx?: ErrorContextContract): Promise<any> | any
636
+ }
637
+
638
+ export interface HandlerContract {
639
+ (ctx?: ContextContract): Promise<any> | any
640
+ }
641
+
642
+ export interface HandleHandlerContract {
643
+ (ctx?: InterceptContextContract): Promise<any> | any
644
+ }
645
+
646
+ export interface InterceptHandlerContract {
647
+ (ctx?: InterceptContextContract): Promise<any> | any
648
+ }
649
+
650
+ export interface TerminateHandlerContract {
651
+ (ctx?: TerminateContextContract): Promise<any> | any
652
+ }
653
+
654
+ export interface MiddlewareContract {
655
+ handle?: HandleHandlerContract
656
+ intercept?: InterceptHandlerContract
657
+ terminate?: TerminateHandlerContract
658
+ }