@adonisjs/http-server 5.12.0 → 6.0.1-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/README.md +15 -38
  2. package/build/index.d.ts +16 -0
  3. package/build/index.js +16 -0
  4. package/build/src/cookies/client.d.ts +12 -0
  5. package/build/src/cookies/client.js +42 -0
  6. package/build/src/cookies/drivers/encrypted.d.ts +4 -0
  7. package/build/src/cookies/drivers/encrypted.js +16 -0
  8. package/build/src/cookies/drivers/plain.d.ts +3 -0
  9. package/build/src/cookies/drivers/plain.js +13 -0
  10. package/build/src/cookies/drivers/signed.d.ts +4 -0
  11. package/build/src/cookies/drivers/signed.js +16 -0
  12. package/build/src/cookies/parser.d.ts +9 -0
  13. package/build/src/cookies/parser.js +69 -0
  14. package/build/src/cookies/serializer.d.ts +11 -0
  15. package/build/src/cookies/serializer.js +39 -0
  16. package/build/src/debug.d.ts +3 -0
  17. package/build/src/debug.js +2 -0
  18. package/build/src/define_config.d.ts +2 -0
  19. package/build/src/define_config.js +40 -0
  20. package/build/src/define_middleware.d.ts +4 -0
  21. package/build/src/define_middleware.js +6 -0
  22. package/build/src/exceptions/abort_exception.d.ts +5 -0
  23. package/build/src/exceptions/abort_exception.js +6 -0
  24. package/build/src/exceptions/cannot_lookup_route.d.ts +5 -0
  25. package/build/src/exceptions/cannot_lookup_route.js +5 -0
  26. package/build/src/exceptions/http_exception.d.ts +6 -0
  27. package/build/src/exceptions/http_exception.js +20 -0
  28. package/build/src/exceptions/route_not_found.d.ts +5 -0
  29. package/build/src/exceptions/route_not_found.js +5 -0
  30. package/build/src/helpers.d.ts +6 -67
  31. package/build/src/helpers.js +13 -168
  32. package/build/src/http_context/local_storage.d.ts +9 -0
  33. package/build/src/http_context/local_storage.js +14 -0
  34. package/build/src/http_context/main.d.ts +20 -0
  35. package/build/src/http_context/main.js +49 -0
  36. package/build/src/middleware/store.d.ts +11 -0
  37. package/build/src/middleware/store.js +33 -0
  38. package/build/src/qs.d.ts +7 -0
  39. package/build/src/qs.js +13 -0
  40. package/build/src/redirect.d.ts +18 -0
  41. package/build/src/redirect.js +80 -0
  42. package/build/src/request.d.ts +81 -0
  43. package/build/src/request.js +315 -0
  44. package/build/src/response.d.ts +108 -0
  45. package/build/src/response.js +587 -0
  46. package/build/src/router/brisk.d.ts +18 -0
  47. package/build/src/router/brisk.js +35 -0
  48. package/build/src/router/executor.d.ts +4 -0
  49. package/build/src/router/executor.js +16 -0
  50. package/build/src/router/group.d.ts +19 -0
  51. package/build/src/router/group.js +117 -0
  52. package/build/src/router/lookup_store/main.d.ts +17 -0
  53. package/build/src/router/lookup_store/main.js +37 -0
  54. package/build/src/router/lookup_store/route_finder.d.ts +8 -0
  55. package/build/src/router/lookup_store/route_finder.js +28 -0
  56. package/build/src/router/lookup_store/url_builder.d.ts +16 -0
  57. package/build/src/router/lookup_store/url_builder.js +111 -0
  58. package/build/src/router/main.d.ts +36 -0
  59. package/build/src/router/main.js +161 -0
  60. package/build/src/router/matchers.d.ts +14 -0
  61. package/build/src/router/matchers.js +15 -0
  62. package/build/src/router/resource.d.ts +27 -0
  63. package/build/src/router/resource.js +124 -0
  64. package/build/src/router/route.d.ts +28 -0
  65. package/build/src/router/route.js +135 -0
  66. package/build/src/router/store.d.ts +12 -0
  67. package/build/src/router/store.js +87 -0
  68. package/build/src/server/factories/final_handler.d.ts +4 -0
  69. package/build/src/server/factories/final_handler.js +17 -0
  70. package/build/src/server/factories/middleware_handler.d.ts +5 -0
  71. package/build/src/server/factories/middleware_handler.js +5 -0
  72. package/build/src/server/factories/use_return_value.d.ts +2 -0
  73. package/build/src/server/factories/use_return_value.js +9 -0
  74. package/build/src/server/factories/write_response.d.ts +2 -0
  75. package/build/src/server/factories/write_response.js +12 -0
  76. package/build/src/server/main.d.ts +23 -0
  77. package/build/src/server/main.js +124 -0
  78. package/build/src/types/base.d.ts +5 -0
  79. package/build/src/types/base.js +1 -0
  80. package/build/src/types/main.d.ts +7 -0
  81. package/build/src/types/main.js +7 -0
  82. package/build/src/types/middleware.d.ts +14 -0
  83. package/build/src/types/middleware.js +1 -0
  84. package/build/src/types/qs.d.ts +15 -0
  85. package/build/src/types/qs.js +1 -0
  86. package/build/src/types/request.d.ts +7 -0
  87. package/build/src/types/request.js +1 -0
  88. package/build/src/types/response.d.ts +18 -0
  89. package/build/src/types/response.js +1 -0
  90. package/build/src/types/route.d.ts +74 -0
  91. package/build/src/types/route.js +1 -0
  92. package/build/src/types/server.d.ts +13 -0
  93. package/build/src/types/server.js +1 -0
  94. package/package.json +88 -86
  95. package/build/adonis-typings/container.d.ts +0 -24
  96. package/build/adonis-typings/container.js +0 -8
  97. package/build/adonis-typings/context.d.ts +0 -73
  98. package/build/adonis-typings/context.js +0 -8
  99. package/build/adonis-typings/cookie-client.d.ts +0 -34
  100. package/build/adonis-typings/cookie-client.js +0 -8
  101. package/build/adonis-typings/http-server.d.ts +0 -98
  102. package/build/adonis-typings/http-server.js +0 -8
  103. package/build/adonis-typings/index.d.ts +0 -16
  104. package/build/adonis-typings/index.js +0 -16
  105. package/build/adonis-typings/middleware.d.ts +0 -95
  106. package/build/adonis-typings/middleware.js +0 -8
  107. package/build/adonis-typings/request.d.ts +0 -556
  108. package/build/adonis-typings/request.js +0 -8
  109. package/build/adonis-typings/response.d.ts +0 -440
  110. package/build/adonis-typings/response.js +0 -8
  111. package/build/adonis-typings/route.d.ts +0 -559
  112. package/build/adonis-typings/route.js +0 -8
  113. package/build/exceptions.json +0 -110
  114. package/build/providers/HttpServerProvider.d.ts +0 -46
  115. package/build/providers/HttpServerProvider.js +0 -100
  116. package/build/src/Cookie/Client/index.d.ts +0 -39
  117. package/build/src/Cookie/Client/index.js +0 -108
  118. package/build/src/Cookie/Drivers/Encrypted.d.ts +0 -24
  119. package/build/src/Cookie/Drivers/Encrypted.js +0 -42
  120. package/build/src/Cookie/Drivers/Plain.d.ts +0 -23
  121. package/build/src/Cookie/Drivers/Plain.js +0 -40
  122. package/build/src/Cookie/Drivers/Signed.d.ts +0 -24
  123. package/build/src/Cookie/Drivers/Signed.js +0 -42
  124. package/build/src/Cookie/Parser/index.d.ts +0 -61
  125. package/build/src/Cookie/Parser/index.js +0 -174
  126. package/build/src/Cookie/Serializer/index.d.ts +0 -46
  127. package/build/src/Cookie/Serializer/index.js +0 -88
  128. package/build/src/Exceptions/HttpException.d.ts +0 -20
  129. package/build/src/Exceptions/HttpException.js +0 -36
  130. package/build/src/Exceptions/RouterException.d.ts +0 -36
  131. package/build/src/Exceptions/RouterException.js +0 -76
  132. package/build/src/HttpContext/LocalStorage/index.d.ts +0 -24
  133. package/build/src/HttpContext/LocalStorage/index.js +0 -28
  134. package/build/src/HttpContext/index.d.ts +0 -90
  135. package/build/src/HttpContext/index.js +0 -181
  136. package/build/src/MiddlewareStore/index.d.ts +0 -92
  137. package/build/src/MiddlewareStore/index.js +0 -133
  138. package/build/src/Redirect/index.d.ts +0 -71
  139. package/build/src/Redirect/index.js +0 -139
  140. package/build/src/Request/index.d.ts +0 -619
  141. package/build/src/Request/index.js +0 -862
  142. package/build/src/Response/index.d.ts +0 -414
  143. package/build/src/Response/index.js +0 -1010
  144. package/build/src/Router/BriskRoute.d.ts +0 -53
  145. package/build/src/Router/BriskRoute.js +0 -74
  146. package/build/src/Router/Group.d.ts +0 -101
  147. package/build/src/Router/Group.js +0 -165
  148. package/build/src/Router/LookupStore.d.ts +0 -122
  149. package/build/src/Router/LookupStore.js +0 -264
  150. package/build/src/Router/Matchers.d.ts +0 -31
  151. package/build/src/Router/Matchers.js +0 -43
  152. package/build/src/Router/Resource.d.ts +0 -95
  153. package/build/src/Router/Resource.js +0 -182
  154. package/build/src/Router/Route.d.ts +0 -138
  155. package/build/src/Router/Route.js +0 -204
  156. package/build/src/Router/Store.d.ts +0 -93
  157. package/build/src/Router/Store.js +0 -211
  158. package/build/src/Router/index.d.ts +0 -142
  159. package/build/src/Router/index.js +0 -333
  160. package/build/src/Server/ExceptionManager/index.d.ts +0 -49
  161. package/build/src/Server/ExceptionManager/index.js +0 -96
  162. package/build/src/Server/Hooks/index.d.ts +0 -43
  163. package/build/src/Server/Hooks/index.js +0 -77
  164. package/build/src/Server/PreCompiler/index.d.ts +0 -60
  165. package/build/src/Server/PreCompiler/index.js +0 -143
  166. package/build/src/Server/RequestHandler/index.d.ts +0 -39
  167. package/build/src/Server/RequestHandler/index.js +0 -87
  168. package/build/src/Server/index.d.ts +0 -90
  169. package/build/src/Server/index.js +0 -175
  170. package/build/standalone.d.ts +0 -14
  171. package/build/standalone.js +0 -23
@@ -1,559 +0,0 @@
1
- /**
2
- * @adonisjs/http-server
3
- *
4
- * (c) Harminder Virk <virk@adonisjs.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- declare module '@ioc:Adonis/Core/Route' {
10
- import { MacroableConstructorContract } from 'macroable';
11
- import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
12
- import { ResolvedMiddlewareHandler } from '@ioc:Adonis/Core/Middleware';
13
- /**
14
- * Route.where param matcher shape
15
- */
16
- export type RouteParamMatcher = string | RegExp | {
17
- match?: RegExp;
18
- cast?: (value: string) => any;
19
- };
20
- /**
21
- * The shape of the route handler
22
- */
23
- export type RouteHandler = ((ctx: HttpContextContract) => any) | string;
24
- /**
25
- * Middleware handler attached to the route.
26
- */
27
- export type RouteMiddlewareHandler = string | ((ctx: HttpContextContract, next: () => void, ...options: any[]) => any);
28
- /**
29
- * Node after resolving controller.method binding from the route
30
- */
31
- export type ResolvedRouteHandler = {
32
- type: 'function';
33
- handler: Exclude<RouteHandler, string>;
34
- } | {
35
- type: 'alias' | 'binding';
36
- namespace: string;
37
- method: string;
38
- };
39
- /**
40
- * Shape of match from the route store
41
- */
42
- export type RouteStoreMatch = {
43
- old: string;
44
- type: number;
45
- val: string;
46
- };
47
- /**
48
- * Shape of route param matchers
49
- */
50
- export type RouteMatchersNode = {
51
- [param: string]: {
52
- match?: RegExp;
53
- cast?: (value: string) => any;
54
- };
55
- };
56
- /**
57
- * Route node persisted within the store
58
- */
59
- export type RouteNode = {
60
- pattern: string;
61
- /**
62
- * The router itself doesn't use the handler for anything, it
63
- * leaves the type to `any` for the consumer to decide the
64
- * shape of the handler
65
- */
66
- handler: RouteHandler;
67
- /**
68
- * The router itself doesn't use the middleware for anything, it
69
- * leaves the type to `any` for the consumer to decide the
70
- * shape of the middleware
71
- */
72
- middleware: RouteMiddlewareHandler[];
73
- /**
74
- * Any custom runtime properties to be added to the route
75
- */
76
- meta: {
77
- resolvedHandler?: ResolvedRouteHandler;
78
- resolvedMiddleware?: ResolvedMiddlewareHandler[];
79
- namespace?: string;
80
- } & Record<string, any>;
81
- /**
82
- * A unique name to lookup routes by name
83
- */
84
- name?: string;
85
- };
86
- /**
87
- * An object of routes for a given HTTP method
88
- */
89
- export type MethodNode = {
90
- tokens: any[];
91
- routes: {
92
- [pattern: string]: RouteNode & {
93
- params: string[];
94
- };
95
- };
96
- };
97
- /**
98
- * Each domain node will have an object of methods and then
99
- * a nested object of routes
100
- */
101
- export type DomainNode = {
102
- [method: string]: MethodNode;
103
- };
104
- /**
105
- * Routes tree is a domain of DomainNodes
106
- */
107
- export type RoutesTree = {
108
- tokens: any[];
109
- domains: {
110
- [domain: string]: DomainNode;
111
- };
112
- };
113
- /**
114
- * Route definition returned as a result of `route.toJSON` method
115
- */
116
- export type RouteJSON = RouteNode & {
117
- methods: string[];
118
- domain?: string;
119
- matchers: RouteMatchersNode;
120
- };
121
- /**
122
- * Shape of the routes tree maintained by the UrlBuilder
123
- */
124
- export type LookupStoreTree = {
125
- [domain: string]: RouteJSON[];
126
- };
127
- /**
128
- * Shape of the matched route for a pattern, method and domain. We set
129
- * them as spread options to the context.
130
- */
131
- export type MatchedRoute = {
132
- route: RouteNode & {
133
- params: string[];
134
- };
135
- /**
136
- * A unique key for the looked up route
137
- */
138
- routeKey: string;
139
- params: Record<string, any>;
140
- subdomains: Record<string, any>;
141
- };
142
- /**
143
- * Shape of route class
144
- */
145
- export interface RouteContract {
146
- /**
147
- * A boolean to prevent route from getting registered within
148
- * the [[Store]].
149
- *
150
- * This flag must be set before [[Router.commit]] method
151
- */
152
- deleted: boolean;
153
- /**
154
- * A unique name to lookup the route
155
- */
156
- name: string;
157
- /**
158
- * Define Regex matcher for a given param. If a matcher exists, then we do not
159
- * override that, since the routes inside a group will set matchers before
160
- * the group, so they should have priority over the route matchers.
161
- *
162
- * ```
163
- * Route.group(() => {
164
- * Route.get('/:id', 'handler').where('id', /^[0-9]$/)
165
- * }).where('id', /[^a-z$]/)
166
- * ```
167
- *
168
- * The `/^[0-9]$/` should win over the matcher defined by the group
169
- */
170
- where(param: string, matcher: RouteParamMatcher): this;
171
- /**
172
- * Define prefix for the route. Prefixes will be concated
173
- * This method is mainly exposed for the [[RouteGroup]]
174
- */
175
- prefix(prefix: string): this;
176
- /**
177
- * Define a custom domain for the route. Again we do not overwrite the domain
178
- * unless `overwrite` flag is set to true.
179
- *
180
- * This is again done to make route.domain win over route.group.domain
181
- */
182
- domain(domain: string): this;
183
- /**
184
- * Define an array of middleware to be executed on the route. If `prepend`
185
- * is true, then middleware will be added to start of the existing
186
- * middleware. The option is exposed for [[RouteGroup]]
187
- */
188
- middleware(middleware: RouteMiddlewareHandler | RouteMiddlewareHandler[], prepend?: boolean): this;
189
- /**
190
- * Give memorizable name to the route. This is helpful, when you
191
- * want to lookup route defination by it's name.
192
- *
193
- * If `prepend` is true, then it will keep on prepending to the existing
194
- * name. This option is exposed for [[RouteGroup]]
195
- */
196
- as(name: string, prepend?: boolean): this;
197
- /**
198
- * Define controller namespace for a given route
199
- */
200
- namespace(namespace: string): this;
201
- /**
202
- * Get the route pattern
203
- */
204
- getPattern(): string;
205
- /**
206
- * Update route pattern
207
- */
208
- setPattern(pattern: string): this;
209
- /**
210
- * Returns [[RouteDefinition]] that can be passed to the [[Store]] for
211
- * registering the route
212
- */
213
- toJSON(): RouteJSON;
214
- }
215
- export type ResourceRouteNames = 'create' | 'index' | 'store' | 'show' | 'edit' | 'update' | 'destroy';
216
- /**
217
- * Shape of route resource class
218
- */
219
- export interface RouteResourceContract {
220
- /**
221
- * A copy of routes that belongs to this resource
222
- */
223
- routes: RouteContract[];
224
- /**
225
- * Register only given routes and remove others
226
- */
227
- only(names: ResourceRouteNames[]): this;
228
- /**
229
- * Register all routes, except the one's defined
230
- */
231
- except(names: ResourceRouteNames[]): this;
232
- /**
233
- * Register api only routes. The `create` and `edit` routes, which
234
- * are meant to show forms will not be registered
235
- */
236
- apiOnly(): this;
237
- /**
238
- * Add middleware to routes inside the resource
239
- */
240
- middleware(middleware: {
241
- [P in ResourceRouteNames]?: RouteMiddlewareHandler | RouteMiddlewareHandler[];
242
- } & {
243
- '*'?: RouteMiddlewareHandler | RouteMiddlewareHandler[];
244
- }): this;
245
- /**
246
- * Define matcher for params inside the resource
247
- */
248
- where(key: string, matcher: RouteParamMatcher): this;
249
- /**
250
- * Define namespace for all the routes inside a given resource
251
- */
252
- namespace(namespace: string): this;
253
- /**
254
- * Set the param name for a given resource
255
- */
256
- paramFor(resource: string, param: string): this;
257
- /**
258
- * Prepend name to the routes names
259
- */
260
- as(name: string): this;
261
- }
262
- /**
263
- * Shape of route group class
264
- */
265
- export interface RouteGroupContract {
266
- routes: (RouteContract | RouteResourceContract | BriskRouteContract | RouteGroupContract)[];
267
- /**
268
- * Define Regex matchers for a given param for all the routes.
269
- *
270
- * @example
271
- * ```ts
272
- * Route.group(() => {
273
- * }).where('id', /^[0-9]+/)
274
- * ```
275
- */
276
- where(param: string, matcher: RouteParamMatcher): this;
277
- /**
278
- * Define prefix all the routes in the group.
279
- *
280
- * @example
281
- * ```ts
282
- * Route.group(() => {
283
- * }).prefix('v1')
284
- * ```
285
- */
286
- prefix(prefix: string): this;
287
- /**
288
- * Define domain for all the routes.
289
- *
290
- * @example
291
- * ```ts
292
- * Route.group(() => {
293
- * }).domain(':name.adonisjs.com')
294
- * ```
295
- */
296
- domain(domain: string): this;
297
- /**
298
- * Prepend name to the routes name.
299
- *
300
- * @example
301
- * ```ts
302
- * Route.group(() => {
303
- * }).as('version1')
304
- * ```
305
- */
306
- as(name: string): this;
307
- /**
308
- * Prepend an array of middleware to all routes middleware.
309
- *
310
- * @example
311
- * ```ts
312
- * Route.group(() => {
313
- * }).middleware(['auth'])
314
- * ```
315
- */
316
- middleware(middleware: RouteMiddlewareHandler | RouteMiddlewareHandler[]): this;
317
- /**
318
- * Define namespace for all the routes inside the group.
319
- *
320
- * @example
321
- * ```ts
322
- * Route.group(() => {
323
- * }).namespace('App/Admin/Controllers')
324
- * ```
325
- */
326
- namespace(namespace: string): this;
327
- }
328
- /**
329
- * Shape for brisk/quick routes
330
- */
331
- export interface BriskRouteContract {
332
- /**
333
- * Reference to route instance. Set after `setHandler` is called
334
- */
335
- route: RouteContract | null;
336
- /**
337
- * Redirect to a given route. Params from the original request will be used when no
338
- * custom params are defined
339
- */
340
- redirect(identifier: string, params?: any[] | Record<string, any>, options?: MakeUrlOptions): RouteContract;
341
- /**
342
- * Redirect request to a fixed path
343
- */
344
- redirectToPath(url: string): RouteContract;
345
- /**
346
- * Set handler for the brisk route. The `invokedBy` string is the reference
347
- * to the method that calls this method. It is required to create human
348
- * readable error message when `setHandler` is called for multiple
349
- * times.
350
- */
351
- setHandler(handler: any, invokedBy: string): RouteContract;
352
- }
353
- /**
354
- * Options accepted by makeUrl methods
355
- */
356
- export type MakeUrlOptions = {
357
- qs?: Record<string, any>;
358
- domain?: string;
359
- prefixUrl?: string;
360
- disableRouteLookup?: boolean;
361
- } & Record<string, any>;
362
- /**
363
- * Options for making a signed url
364
- */
365
- export type MakeSignedUrlOptions = MakeUrlOptions & {
366
- expiresIn?: string | number;
367
- purpose?: string;
368
- };
369
- /**
370
- * Shape of router exposed for creating routes
371
- */
372
- export interface RouterContract extends LookupStoreContract {
373
- /**
374
- * Exposing BriskRoute, RouteGroup and RouteResource constructors
375
- * to be extended from outside
376
- */
377
- BriskRoute: MacroableConstructorContract<BriskRouteContract>;
378
- RouteGroup: MacroableConstructorContract<RouteGroupContract>;
379
- RouteResource: MacroableConstructorContract<RouteResourceContract>;
380
- Route: MacroableConstructorContract<RouteContract>;
381
- RouteMatchers: MacroableConstructorContract<RouteMatchersContract>;
382
- /**
383
- * Collection of routes, including route resource and route
384
- * group. To get a flat list of routes, call `router.toJSON()`
385
- */
386
- routes: (RouteContract | RouteResourceContract | RouteGroupContract | BriskRouteContract)[];
387
- /**
388
- * Add route for a given pattern and methods
389
- */
390
- route(pattern: string, methods: string[], handler: RouteHandler): RouteContract;
391
- /**
392
- * Define a route that handles all common HTTP methods
393
- */
394
- any(pattern: string, handler: RouteHandler): RouteContract;
395
- /**
396
- * Define `GET` route
397
- */
398
- get(pattern: string, handler: RouteHandler): RouteContract;
399
- /**
400
- * Define `POST` route
401
- */
402
- post(pattern: string, handler: RouteHandler): RouteContract;
403
- /**
404
- * Define `PUT` route
405
- */
406
- put(pattern: string, handler: RouteHandler): RouteContract;
407
- /**
408
- * Define `PATCH` route
409
- */
410
- patch(pattern: string, handler: RouteHandler): RouteContract;
411
- /**
412
- * Define `DELETE` route
413
- */
414
- delete(pattern: string, handler: RouteHandler): RouteContract;
415
- /**
416
- * Creates a group of routes. A route group can apply transforms
417
- * to routes in bulk
418
- */
419
- group(callback: () => void): RouteGroupContract;
420
- /**
421
- * Registers a route resource with conventional set of routes
422
- */
423
- resource(resource: string, controller: string): RouteResourceContract;
424
- /**
425
- * Register a route resource with shallow nested routes.
426
- */
427
- shallowResource(resource: string, controller: string): RouteResourceContract;
428
- /**
429
- * Returns a brisk route instance for a given URL pattern
430
- */
431
- on(pattern: string): BriskRouteContract;
432
- /**
433
- * Define global route matcher
434
- */
435
- where(key: string, matcher: RouteParamMatcher): this;
436
- /**
437
- * Returns a flat list of routes JSON
438
- */
439
- toJSON(): {
440
- [domain: string]: (RouteNode & {
441
- methods: string[];
442
- })[];
443
- };
444
- /**
445
- * Commit routes to the store. After this, no more
446
- * routes can be registered.
447
- */
448
- commit(): void;
449
- /**
450
- * Find route for a given URL, method and optionally domain
451
- */
452
- match(url: string, method: string, domain?: string): null | MatchedRoute;
453
- /**
454
- * Makes url to a registered route by looking it up with the route pattern,
455
- * name or the controller.method
456
- */
457
- makeUrl(routeIdentifier: string, params?: any[] | MakeUrlOptions, options?: MakeUrlOptions): string;
458
- /**
459
- * Makes a signed url, which can be confirmed for it's integrity without
460
- * relying on any sort of backend storage.
461
- */
462
- makeSignedUrl(routeIdentifier: string, params?: any[] | MakeSignedUrlOptions, options?: MakeSignedUrlOptions): string;
463
- /**
464
- * Shortcut methods for defining route param matchers
465
- */
466
- matchers: RouteMatchersContract;
467
- }
468
- /**
469
- * Shortcut methods for commonly used route matchers
470
- */
471
- export interface RouteMatchersContract {
472
- /**
473
- * Enforce value to be a number and also casts it to number data
474
- * type
475
- */
476
- number(): {
477
- match: RegExp;
478
- cast: (value: string) => number;
479
- };
480
- /**
481
- * Enforce value to be formatted as uuid
482
- */
483
- uuid(): {
484
- match: RegExp;
485
- cast: (value: string) => string;
486
- };
487
- /**
488
- * Enforce value to be formatted as slug
489
- */
490
- slug(): {
491
- match: RegExp;
492
- };
493
- }
494
- /**
495
- * Lookup store allows making urls to a given route by performing
496
- * lookup using its name, route handler or the route pattern
497
- * directly
498
- */
499
- export interface LookupStoreContract {
500
- /**
501
- * Find a route by indentifier. Optionally one can find routes inside
502
- * a given domain
503
- */
504
- find(routeIdentifier: string, domainPattern?: string): RouteJSON | null;
505
- /**
506
- * Find a route by indentifier or fail. Optionally one can find routes inside
507
- * a given domain
508
- */
509
- findOrFail(routeIdentifier: string, domainPattern?: string): RouteJSON;
510
- /**
511
- * Find if a route for given identifier exists. Optionally one can find routes inside
512
- * a given domain
513
- */
514
- has(routeIdentifier: string, domainPattern?: string): boolean;
515
- /**
516
- * Get the builder instance for the main domain
517
- */
518
- builder(): UrlBuilderContract;
519
- /**
520
- * Get the builder instance for a specific domain
521
- */
522
- builderForDomain(domainPattern: string): UrlBuilderContract;
523
- }
524
- /**
525
- * Shape of the Url builder
526
- */
527
- export interface UrlBuilderContract {
528
- /**
529
- * Prefix a custom url to the final URI
530
- */
531
- params(params?: any[] | Record<string, any>): this;
532
- /**
533
- * Append query string to the final URI
534
- */
535
- qs(qs?: Record<string, any>): this;
536
- /**
537
- * Define required params to resolve the route
538
- */
539
- prefixUrl(url: string): this;
540
- /**
541
- * Generate url for the given route
542
- */
543
- make(identifier: string): string;
544
- /**
545
- * Disable route lookup and consider identifier
546
- * as the route pattern
547
- */
548
- disableRouteLookup(): this;
549
- /**
550
- * Generate signed url for the given route
551
- */
552
- makeSigned(identifier: string, options?: {
553
- expiresIn?: string | number;
554
- purpose?: string;
555
- }): string;
556
- }
557
- const Route: RouterContract;
558
- export default Route;
559
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * @adonisjs/http-server
3
- *
4
- * (c) Harminder Virk <virk@adonisjs.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
@@ -1,110 +0,0 @@
1
- {
2
- "E_CANNOT_LOOKUP_ROUTE": {
3
- "message": "Cannot find route for \"{{ identifier }}\" identifier",
4
- "code": "E_CANNOT_FIND_ROUTE",
5
- "status": 500,
6
- "help": [
7
- "When making URL for a route. You can use one of the following identifiers",
8
- "- The route name. Defined using `Route.as()`",
9
- "- The route controller.method name. `PostsController.show`"
10
- ]
11
- },
12
- "E_CANNOT_LOOKUP_DOMAIN": {
13
- "message": "Cannot find routes for \"{{ domain }}\" domain",
14
- "code": "E_CANNOT_FIND_ROUTE_DOMAIN",
15
- "status": 500,
16
- "help": [
17
- "When making routes for a domain. Make sure",
18
- "- You pass in the domain pattern and not the actual URL",
19
- "- The domain pattern should be defined inside the routes file"
20
- ]
21
- },
22
- "E_CANNOT_SERIALIZE_RESPONSE_BODY": {
23
- "message": "Unable to send HTTP response. Cannot serialize \"{{ dataType }}\" to a string",
24
- "code": "E_CANNOT_SERIALIZE_RESPONSE_BODY",
25
- "status": 500,
26
- "help": [
27
- "AdonisJS can only send following data types as a response",
28
- "- object, array, number, boolean, date, buffer and string",
29
- "- For sending streams, you must use `response.stream` method",
30
- "- For downloading files, you must use `response.download` method"
31
- ]
32
- },
33
- "E_HTTP_EXCEPTION": {
34
- "message": "Request aborted with status code {{ status }}",
35
- "code": "E_HTTP_EXCEPTION",
36
- "help": ["A generic exception usually raised using \"response.abort\""]
37
- },
38
- "E_CANNOT_DEFINE_GROUP_NAME": {
39
- "message": "All the routes inside a group must have names before calling \"Route.group.as\"",
40
- "code": "E_CANNOT_DEFINE_GROUP_NAME",
41
- "status": 500,
42
- "help": [
43
- "`Route.group.as` adds a prefix to the route names and hence it cannot prefix a route with no initial name",
44
- "To fix the issue, you must give name to all the routes inside a group"
45
- ]
46
- },
47
- "E_DUPLICATE_ROUTE_NAME": {
48
- "message": "Duplicate route name \"{{ name }}\"",
49
- "code": "E_DUPLICATE_ROUTE_NAME",
50
- "status": 500,
51
- "help": [
52
- "Names are assigned to the routes to identify them uniquely and hence a duplicate name is not allowed",
53
- "Run `node ace list:routes` to find the route using this name"
54
- ]
55
- },
56
- "E_DUPLICATE_ROUTE": {
57
- "message": "Duplicate route \"{{ method }}:{{ pattern }}\"",
58
- "code": "E_DUPLICATE_ROUTE",
59
- "status": 500,
60
- "help": [
61
- "The route with the pattern is already registered",
62
- "Double check your routes file or run `node ace list:routes`"
63
- ]
64
- },
65
- "E_DUPLICATE_ROUTE_PARAM": {
66
- "message": "The \"{{ param }}\" param is mentioned twice in the route pattern \"{{ pattern }}\"",
67
- "code": "E_DUPLICATE_ROUTE_PARAM",
68
- "status": 500
69
- },
70
- "E_ROUTE_NOT_FOUND": {
71
- "message": "Cannot {{ method }}:{{ url }}",
72
- "code": "E_ROUTE_NOT_FOUND",
73
- "status": 404
74
- },
75
- "E_MISSING_NAMED_MIDDLEWARE": {
76
- "message": "Cannot find a middleware named \"{{ name }}\"",
77
- "code": "E_MISSING_NAMED_MIDDLEWARE",
78
- "status": 500,
79
- "help": [
80
- "The named middleware are supposed to be registered inside `start/kernel` file first",
81
- "Open the file and make sure middleware is defined inside `Server.middleware.registerNamed()` call"
82
- ]
83
- },
84
- "E_CANNOT_MAKE_ROUTE_URL": {
85
- "message": "\"{{ param }}\" param is required to make URL for \"{{ pattern }}\" route",
86
- "code": "E_CANNOT_MAKE_ROUTE_URL",
87
- "status": 500,
88
- "help": [
89
- "Make sure to define params object when using `Route.makeUrl` or the view help `route`."
90
- ]
91
- },
92
- "E_INVALID_ALS_ACCESS": {
93
- "message": "HTTP context is not available. Set \"useAsyncLocalStorage\" to true inside \"config/app.ts\" file",
94
- "code": "E_INVALID_ALS_ACCESS",
95
- "status": 500,
96
- "help": [
97
- "HttpContext.getOrFail method returns the HTTP context only when Async local storage is enabled",
98
- "- Either, you must enable it insie the config/app.ts file",
99
- "- Or remove the usage of HttpContext.getOrFail method"
100
- ]
101
- },
102
- "E_INVALID_ALS_SCOPE": {
103
- "message": "Http context is not available outside of an HTTP request",
104
- "code": "E_INVALID_ALS_SCOPE",
105
- "status": 500,
106
- "help": [
107
- "Make sure the code that attempts to access the HttpContext is running within the scope of an HTTP request"
108
- ]
109
- }
110
- }