@adonisjs/http-server 6.8.2-5 → 6.8.2-7

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 (208) hide show
  1. package/README.md +3 -6
  2. package/build/factories/http_context.d.ts +10 -1
  3. package/build/factories/http_context.js +27 -0
  4. package/build/factories/http_server.d.ts +8 -0
  5. package/build/factories/http_server.js +26 -0
  6. package/build/factories/main.d.ts +0 -1
  7. package/build/factories/main.js +8 -0
  8. package/build/factories/qs_parser_factory.d.ts +10 -1
  9. package/build/factories/qs_parser_factory.js +18 -0
  10. package/build/factories/request.d.ts +10 -1
  11. package/build/factories/request.js +31 -0
  12. package/build/factories/response.d.ts +10 -1
  13. package/build/factories/response.js +34 -0
  14. package/build/factories/router.d.ts +10 -1
  15. package/build/factories/router.js +25 -0
  16. package/build/factories/server_factory.d.ts +10 -1
  17. package/build/factories/server_factory.js +34 -0
  18. package/build/index.d.ts +0 -1
  19. package/build/index.js +8 -0
  20. package/build/src/cookies/client.d.ts +25 -1
  21. package/build/src/cookies/client.js +42 -0
  22. package/build/src/cookies/drivers/encrypted.d.ts +12 -1
  23. package/build/src/cookies/drivers/encrypted.js +20 -0
  24. package/build/src/cookies/drivers/plain.d.ts +12 -1
  25. package/build/src/cookies/drivers/plain.js +20 -0
  26. package/build/src/cookies/drivers/signed.d.ts +12 -1
  27. package/build/src/cookies/drivers/signed.js +20 -0
  28. package/build/src/cookies/parser.d.ts +28 -1
  29. package/build/src/cookies/parser.js +98 -0
  30. package/build/src/cookies/serializer.d.ts +22 -1
  31. package/build/src/cookies/serializer.js +40 -0
  32. package/build/src/debug.d.ts +0 -1
  33. package/build/src/debug.js +8 -0
  34. package/build/src/define_config.d.ts +3 -1
  35. package/build/src/define_config.js +11 -0
  36. package/build/src/define_middleware.d.ts +5 -1
  37. package/build/src/define_middleware.js +18 -0
  38. package/build/src/exception_handler.d.ts +65 -1
  39. package/build/src/exception_handler.js +95 -0
  40. package/build/src/exceptions.d.ts +6 -1
  41. package/build/src/exceptions.js +11 -0
  42. package/build/src/helpers.d.ts +14 -1
  43. package/build/src/helpers.js +22 -0
  44. package/build/src/http_context/local_storage.d.ts +3 -1
  45. package/build/src/http_context/local_storage.js +25 -0
  46. package/build/src/http_context/main.d.ts +36 -1
  47. package/build/src/http_context/main.js +54 -0
  48. package/build/src/qs.d.ts +4 -1
  49. package/build/src/qs.js +12 -0
  50. package/build/src/redirect.d.ts +24 -1
  51. package/build/src/redirect.js +60 -0
  52. package/build/src/request.d.ts +466 -1
  53. package/build/src/request.js +542 -0
  54. package/build/src/response.d.ts +425 -2
  55. package/build/src/response.js +608 -7
  56. package/build/src/router/brisk.d.ts +22 -1
  57. package/build/src/router/brisk.js +42 -0
  58. package/build/src/router/executor.d.ts +4 -1
  59. package/build/src/router/executor.js +12 -0
  60. package/build/src/router/factories/use_return_value.d.ts +4 -1
  61. package/build/src/router/factories/use_return_value.js +16 -3
  62. package/build/src/router/group.d.ts +47 -1
  63. package/build/src/router/group.js +88 -0
  64. package/build/src/router/lookup_store/main.d.ts +32 -1
  65. package/build/src/router/lookup_store/main.js +49 -0
  66. package/build/src/router/lookup_store/route_finder.d.ts +13 -1
  67. package/build/src/router/lookup_store/route_finder.js +21 -0
  68. package/build/src/router/lookup_store/url_builder.d.ts +36 -1
  69. package/build/src/router/lookup_store/url_builder.js +97 -0
  70. package/build/src/router/main.d.ts +87 -1
  71. package/build/src/router/main.js +142 -0
  72. package/build/src/router/matchers.d.ts +13 -1
  73. package/build/src/router/matchers.js +21 -0
  74. package/build/src/router/parser.d.ts +3 -1
  75. package/build/src/router/parser.js +12 -0
  76. package/build/src/router/resource.d.ts +28 -1
  77. package/build/src/router/resource.js +90 -0
  78. package/build/src/router/route.d.ts +65 -1
  79. package/build/src/router/route.js +142 -0
  80. package/build/src/router/store.d.ts +54 -1
  81. package/build/src/router/store.js +102 -0
  82. package/build/src/server/factories/final_handler.d.ts +5 -1
  83. package/build/src/server/factories/final_handler.js +13 -0
  84. package/build/src/server/factories/middleware_handler.d.ts +3 -1
  85. package/build/src/server/factories/middleware_handler.js +11 -0
  86. package/build/src/server/factories/write_response.d.ts +4 -1
  87. package/build/src/server/factories/write_response.js +12 -0
  88. package/build/src/server/main.d.ts +48 -1
  89. package/build/src/server/main.js +128 -0
  90. package/build/src/types/base.d.ts +12 -1
  91. package/build/src/types/base.js +8 -0
  92. package/build/src/types/main.d.ts +0 -1
  93. package/build/src/types/main.js +8 -0
  94. package/build/src/types/middleware.d.ts +18 -1
  95. package/build/src/types/middleware.js +8 -0
  96. package/build/src/types/qs.d.ts +53 -1
  97. package/build/src/types/qs.js +8 -0
  98. package/build/src/types/request.d.ts +32 -1
  99. package/build/src/types/request.js +8 -0
  100. package/build/src/types/response.d.ts +27 -1
  101. package/build/src/types/response.js +8 -0
  102. package/build/src/types/route.d.ts +87 -1
  103. package/build/src/types/route.js +8 -0
  104. package/build/src/types/server.d.ts +35 -1
  105. package/build/src/types/server.js +8 -0
  106. package/package.json +43 -70
  107. package/build/factories/http_context.d.ts.map +0 -1
  108. package/build/factories/main.d.ts.map +0 -1
  109. package/build/factories/qs_parser_factory.d.ts.map +0 -1
  110. package/build/factories/request.d.ts.map +0 -1
  111. package/build/factories/response.d.ts.map +0 -1
  112. package/build/factories/router.d.ts.map +0 -1
  113. package/build/factories/server_factory.d.ts.map +0 -1
  114. package/build/index.d.ts.map +0 -1
  115. package/build/src/cookies/client.d.ts.map +0 -1
  116. package/build/src/cookies/drivers/encrypted.d.ts.map +0 -1
  117. package/build/src/cookies/drivers/plain.d.ts.map +0 -1
  118. package/build/src/cookies/drivers/signed.d.ts.map +0 -1
  119. package/build/src/cookies/parser.d.ts.map +0 -1
  120. package/build/src/cookies/serializer.d.ts.map +0 -1
  121. package/build/src/debug.d.ts.map +0 -1
  122. package/build/src/define_config.d.ts.map +0 -1
  123. package/build/src/define_middleware.d.ts.map +0 -1
  124. package/build/src/exception_handler.d.ts.map +0 -1
  125. package/build/src/exceptions.d.ts.map +0 -1
  126. package/build/src/helpers.d.ts.map +0 -1
  127. package/build/src/http_context/local_storage.d.ts.map +0 -1
  128. package/build/src/http_context/main.d.ts.map +0 -1
  129. package/build/src/qs.d.ts.map +0 -1
  130. package/build/src/redirect.d.ts.map +0 -1
  131. package/build/src/request.d.ts.map +0 -1
  132. package/build/src/response.d.ts.map +0 -1
  133. package/build/src/router/brisk.d.ts.map +0 -1
  134. package/build/src/router/executor.d.ts.map +0 -1
  135. package/build/src/router/factories/use_return_value.d.ts.map +0 -1
  136. package/build/src/router/group.d.ts.map +0 -1
  137. package/build/src/router/lookup_store/main.d.ts.map +0 -1
  138. package/build/src/router/lookup_store/route_finder.d.ts.map +0 -1
  139. package/build/src/router/lookup_store/url_builder.d.ts.map +0 -1
  140. package/build/src/router/main.d.ts.map +0 -1
  141. package/build/src/router/matchers.d.ts.map +0 -1
  142. package/build/src/router/parser.d.ts.map +0 -1
  143. package/build/src/router/resource.d.ts.map +0 -1
  144. package/build/src/router/route.d.ts.map +0 -1
  145. package/build/src/router/store.d.ts.map +0 -1
  146. package/build/src/server/factories/final_handler.d.ts.map +0 -1
  147. package/build/src/server/factories/middleware_handler.d.ts.map +0 -1
  148. package/build/src/server/factories/write_response.d.ts.map +0 -1
  149. package/build/src/server/main.d.ts.map +0 -1
  150. package/build/src/types/base.d.ts.map +0 -1
  151. package/build/src/types/main.d.ts.map +0 -1
  152. package/build/src/types/middleware.d.ts.map +0 -1
  153. package/build/src/types/qs.d.ts.map +0 -1
  154. package/build/src/types/request.d.ts.map +0 -1
  155. package/build/src/types/response.d.ts.map +0 -1
  156. package/build/src/types/route.d.ts.map +0 -1
  157. package/build/src/types/server.d.ts.map +0 -1
  158. package/factories/http_context.ts +0 -73
  159. package/factories/main.ts +0 -15
  160. package/factories/qs_parser_factory.ts +0 -54
  161. package/factories/request.ts +0 -101
  162. package/factories/response.ts +0 -106
  163. package/factories/router.ts +0 -61
  164. package/factories/server_factory.ts +0 -94
  165. package/index.ts +0 -23
  166. package/src/cookies/client.ts +0 -98
  167. package/src/cookies/drivers/encrypted.ts +0 -42
  168. package/src/cookies/drivers/plain.ts +0 -37
  169. package/src/cookies/drivers/signed.ts +0 -42
  170. package/src/cookies/parser.ts +0 -196
  171. package/src/cookies/serializer.ts +0 -98
  172. package/src/debug.ts +0 -11
  173. package/src/define_config.ts +0 -56
  174. package/src/define_middleware.ts +0 -61
  175. package/src/exception_handler.ts +0 -290
  176. package/src/exceptions.ts +0 -55
  177. package/src/helpers.ts +0 -108
  178. package/src/http_context/local_storage.ts +0 -50
  179. package/src/http_context/main.ts +0 -126
  180. package/src/qs.ts +0 -31
  181. package/src/redirect.ts +0 -181
  182. package/src/request.ts +0 -982
  183. package/src/response.ts +0 -1421
  184. package/src/router/brisk.ts +0 -113
  185. package/src/router/executor.ts +0 -36
  186. package/src/router/factories/use_return_value.ts +0 -26
  187. package/src/router/group.ts +0 -243
  188. package/src/router/lookup_store/main.ts +0 -102
  189. package/src/router/lookup_store/route_finder.ts +0 -60
  190. package/src/router/lookup_store/url_builder.ts +0 -250
  191. package/src/router/main.ts +0 -431
  192. package/src/router/matchers.ts +0 -40
  193. package/src/router/parser.ts +0 -20
  194. package/src/router/resource.ts +0 -277
  195. package/src/router/route.ts +0 -363
  196. package/src/router/store.ts +0 -239
  197. package/src/server/factories/final_handler.ts +0 -38
  198. package/src/server/factories/middleware_handler.ts +0 -23
  199. package/src/server/factories/write_response.ts +0 -26
  200. package/src/server/main.ts +0 -356
  201. package/src/types/base.ts +0 -30
  202. package/src/types/main.ts +0 -16
  203. package/src/types/middleware.ts +0 -59
  204. package/src/types/qs.ts +0 -85
  205. package/src/types/request.ts +0 -52
  206. package/src/types/response.ts +0 -57
  207. package/src/types/route.ts +0 -217
  208. package/src/types/server.ts +0 -92
@@ -1,16 +1,68 @@
1
1
  export type QSParserConfig = {
2
2
  parse: {
3
+ /**
4
+ * Nesting depth till the parameters should be parsed.
5
+ *
6
+ * Defaults to 5
7
+ */
3
8
  depth: number;
9
+ /**
10
+ * Number of parameters to parse.
11
+ *
12
+ * Defaults to 1000
13
+ */
4
14
  parameterLimit: number;
15
+ /**
16
+ * Allow sparse elements in an array.
17
+ *
18
+ * Defaults to false
19
+ */
5
20
  allowSparse: boolean;
21
+ /**
22
+ * The max limimit for the array indices. After the given limit
23
+ * the array indices will be converted to an object, where the
24
+ * index is the key.
25
+ *
26
+ * Defaults to 20
27
+ */
6
28
  arrayLimit: number;
29
+ /**
30
+ * Join comma seperated query string values to an array
31
+ *
32
+ * Defaults to false
33
+ */
7
34
  comma: boolean;
8
35
  };
9
36
  stringify: {
37
+ /**
38
+ * URI encode the stringified query string
39
+ *
40
+ * Defaults to true
41
+ */
10
42
  encode: boolean;
43
+ /**
44
+ * URI encode but only the values and not the keys
45
+ *
46
+ * Defaults to false
47
+ */
11
48
  encodeValuesOnly: boolean;
49
+ /**
50
+ * Define the format in which arrays should be serialized.
51
+ *
52
+ * - indices: a[0]=b&a[1]=c
53
+ * - brackets: a[]=b&a[]=c
54
+ * - repeat: a=b&a=c
55
+ * - comma: a=b,c
56
+ *
57
+ * Defaults to "indices"
58
+ */
12
59
  arrayFormat: 'indices' | 'brackets' | 'repeat' | 'comma';
60
+ /**
61
+ * Whether or not to skip null values when serializing. When set to
62
+ * false, the null values will be treated as an empty string.
63
+ *
64
+ * Defaults to: false
65
+ */
13
66
  skipNulls: boolean;
14
67
  };
15
68
  };
16
- //# sourceMappingURL=qs.d.ts.map
@@ -1 +1,9 @@
1
+ /*
2
+ * @adonisjs/http-server
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
1
9
  export {};
@@ -1,8 +1,39 @@
1
+ /**
2
+ * Shape of the request config
3
+ */
1
4
  export type RequestConfig = {
5
+ /**
6
+ * URL segments to ignore when extracting subdomains from a URL.
7
+ * Defaults to 2
8
+ */
2
9
  subdomainOffset: number;
10
+ /**
11
+ * Enabling the flag will generated a unique request id from every
12
+ * HTTP request.
13
+ *
14
+ * The request id can be accessed using the "request.id()" method. Also,
15
+ * the value of `x-request-id` header is used as the id (if it exists).
16
+ *
17
+ * Defaults to false
18
+ */
3
19
  generateRequestId: boolean;
20
+ /**
21
+ * Method spoofing allows changing the request method using the query string.
22
+ * For example: Making a POST request on URL /users/1?_method=PATCH will
23
+ * be handled by the patch route.
24
+ *
25
+ * Defaults to false
26
+ */
4
27
  allowMethodSpoofing: boolean;
28
+ /**
29
+ * A custom implementation to get the request ip address
30
+ */
5
31
  getIp?: (request: any) => string;
32
+ /**
33
+ * A callback function to trust proxy ip addresses. You must use
34
+ * the `proxy-addr` package to compute this value.
35
+ *
36
+ * Defaults to: "proxyAddr.compile('loopback')"
37
+ */
6
38
  trustProxy: (address: string, distance: number) => boolean;
7
39
  };
8
- //# sourceMappingURL=request.d.ts.map
@@ -1 +1,9 @@
1
+ /*
2
+ * @adonisjs/http-server
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
1
9
  export {};
@@ -1,5 +1,8 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  /// <reference types="node" resolution-mode="require"/>
3
+ /**
4
+ * Cookie options can that can be set on the response
5
+ */
3
6
  export type CookieOptions = {
4
7
  domain: string;
5
8
  expires: Date | (() => Date);
@@ -9,11 +12,34 @@ export type CookieOptions = {
9
12
  sameSite: boolean | 'lax' | 'none' | 'strict';
10
13
  secure: boolean;
11
14
  };
15
+ /**
16
+ * Types from which response header can be casted to a
17
+ * string
18
+ */
12
19
  export type CastableHeader = string | number | boolean | string[] | number[] | boolean[];
20
+ /**
21
+ * Config accepted by response the class
22
+ */
13
23
  export type ResponseConfig = {
24
+ /**
25
+ * Whether or not to generate etags for responses. Etags can be
26
+ * enabled/disabled when sending response as well.
27
+ *
28
+ * Defaults to false
29
+ */
14
30
  etag: boolean;
31
+ /**
32
+ * The callback name for the JSONP response.
33
+ *
34
+ * Defaults to 'callback'
35
+ */
15
36
  jsonpCallbackName: string;
37
+ /**
38
+ * Options to set cookies
39
+ */
16
40
  cookie: Partial<CookieOptions>;
17
41
  };
42
+ /**
43
+ * Stream that can be piped to the "response.stream" method
44
+ */
18
45
  export type ResponseStream = NodeJS.ReadStream | NodeJS.ReadWriteStream | NodeJS.ReadableStream;
19
- //# sourceMappingURL=response.d.ts.map
@@ -1 +1,9 @@
1
+ /*
2
+ * @adonisjs/http-server
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
1
9
  export {};
@@ -3,32 +3,73 @@ import type { ContainerResolver } from '@adonisjs/fold';
3
3
  import type { Constructor, LazyImport } from './base.js';
4
4
  import type { HttpContext } from '../http_context/main.js';
5
5
  import type { MiddlewareFn, ParsedGlobalMiddleware } from './middleware.js';
6
+ /**
7
+ * Returns a union of methods from a controller that accepts
8
+ * the context as the first argument.
9
+ */
6
10
  export type GetControllerHandlers<Controller extends Constructor<any>> = {
7
11
  [K in keyof InstanceType<Controller>]: InstanceType<Controller>[K] extends (ctx: HttpContext, ...args: any[]) => any ? K : never;
8
12
  }[keyof InstanceType<Controller>];
13
+ /**
14
+ * Route token stored by matchit library
15
+ */
9
16
  export type MatchItRouteToken = RouteMatcher & {
10
17
  old: string;
11
18
  type: 0 | 1 | 2 | 3;
12
19
  val: string;
13
20
  end: string;
14
21
  };
22
+ /**
23
+ * Route handler defined as a function
24
+ */
15
25
  export type RouteFn = (ctx: HttpContext) => any;
26
+ /**
27
+ * Route handler persisted with the route store
28
+ */
16
29
  export type StoreRouteHandler = RouteFn | {
17
30
  reference: string | [LazyImport<Constructor<any>> | Constructor<any>, any?];
18
31
  handle: (resolver: ContainerResolver<any>, ...args: [ctx: HttpContext, ...injections: any[]]) => any;
19
32
  };
33
+ /**
34
+ * The middleware persisted with the route store
35
+ */
20
36
  export type StoreRouteMiddleware = MiddlewareFn | ({
21
37
  name?: string;
22
38
  args?: any[];
23
39
  } & ParsedGlobalMiddleware);
40
+ /**
41
+ * Route node persisted within the routes store
42
+ */
24
43
  export type StoreRouteNode = {
44
+ /**
45
+ * The execute function to execute the route middleware
46
+ * and the handler
47
+ */
25
48
  execute: (route: StoreRouteNode, resolver: ContainerResolver<any>, ctx: HttpContext) => any;
49
+ /**
50
+ * A unique name for the route
51
+ */
26
52
  name?: string;
53
+ /**
54
+ * Route URI pattern
55
+ */
27
56
  pattern: string;
57
+ /**
58
+ * Route handler
59
+ */
28
60
  handler: StoreRouteHandler;
61
+ /**
62
+ * Route middleware
63
+ */
29
64
  middleware: Middleware<StoreRouteMiddleware>;
65
+ /**
66
+ * Additional metadata associated with the route
67
+ */
30
68
  meta: Record<string, any>;
31
69
  };
70
+ /**
71
+ * An object of routes for a given HTTP method
72
+ */
32
73
  export type StoreMethodNode = {
33
74
  tokens: MatchItRouteToken[][];
34
75
  routeKeys: {
@@ -38,42 +79,87 @@ export type StoreMethodNode = {
38
79
  [pattern: string]: StoreRouteNode;
39
80
  };
40
81
  };
82
+ /**
83
+ * Each domain node container an object of methods. Each method
84
+ * object has nested routes.
85
+ */
41
86
  export type StoreDomainNode = {
42
87
  [method: string]: StoreMethodNode;
43
88
  };
89
+ /**
90
+ * Routes tree stored within the routes store
91
+ */
44
92
  export type StoreRoutesTree = {
45
93
  tokens: MatchItRouteToken[][];
46
94
  domains: {
47
95
  [domain: string]: StoreDomainNode;
48
96
  };
49
97
  };
98
+ /**
99
+ * Shape of the matched route for a pattern, method and domain.
100
+ */
50
101
  export type MatchedRoute = {
51
102
  route: StoreRouteNode;
103
+ /**
104
+ * A unique key for the looked up route
105
+ */
52
106
  routeKey: string;
107
+ /**
108
+ * Route params
109
+ */
53
110
  params: Record<string, any>;
111
+ /**
112
+ * Route subdomains (if part of a subdomain)
113
+ */
54
114
  subdomains: Record<string, any>;
55
115
  };
116
+ /**
117
+ * Shape of a route param matcher
118
+ */
56
119
  export type RouteMatcher = {
57
120
  match?: RegExp;
58
121
  cast?: (value: string) => any;
59
122
  };
123
+ /**
124
+ * A collection of route matchers
125
+ */
60
126
  export type RouteMatchers = {
61
127
  [param: string]: RouteMatcher;
62
128
  };
129
+ /**
130
+ * Representation of a route as JSON
131
+ */
63
132
  export type RouteJSON = StoreRouteNode & {
133
+ /**
134
+ * HTTP methods, the route responds to.
135
+ */
64
136
  methods: string[];
137
+ /**
138
+ * The domain for which the route is registered.
139
+ */
65
140
  domain: string;
141
+ /**
142
+ * Matchers for route params.
143
+ */
66
144
  matchers: RouteMatchers;
67
145
  };
146
+ /**
147
+ * Resource action names
148
+ */
68
149
  export type ResourceActionNames = 'create' | 'index' | 'store' | 'show' | 'edit' | 'update' | 'destroy';
150
+ /**
151
+ * Options accepted by makeUrl method
152
+ */
69
153
  export type MakeUrlOptions = {
70
154
  qs?: Record<string, any>;
71
155
  domain?: string;
72
156
  prefixUrl?: string;
73
157
  disableRouteLookup?: boolean;
74
158
  };
159
+ /**
160
+ * Options accepted by makeSignedUrl method
161
+ */
75
162
  export type MakeSignedUrlOptions = MakeUrlOptions & {
76
163
  expiresIn?: string | number;
77
164
  purpose?: string;
78
165
  };
79
- //# sourceMappingURL=route.d.ts.map
@@ -1 +1,9 @@
1
+ /*
2
+ * @adonisjs/http-server
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
1
9
  export {};
@@ -4,6 +4,10 @@ import type { QSParserConfig } from './qs.js';
4
4
  import type { RequestConfig } from './request.js';
5
5
  import type { ResponseConfig } from './response.js';
6
6
  import type { HttpContext } from '../http_context/main.js';
7
+ /**
8
+ * Normalized HTTP error used by the exception
9
+ * handler.
10
+ */
7
11
  export type HttpError = {
8
12
  message: string;
9
13
  status: number;
@@ -15,24 +19,54 @@ export type HttpError = {
15
19
  handle?: (...args: any[]) => any;
16
20
  report?: (...args: any[]) => any;
17
21
  };
22
+ /**
23
+ * The pipeline for executing middleware during tests
24
+ */
18
25
  export interface TestingMiddlewarePipeline {
19
26
  finalHandler(handler: FinalHandler): this;
20
27
  errorHandler(handler: ErrorHandler): this;
21
28
  run(ctx: HttpContext): Promise<any>;
22
29
  }
30
+ /**
31
+ * The expression to define a status page range
32
+ */
23
33
  export type StatusPageRange = `${number}..${number}`;
34
+ /**
35
+ * The callback function to render status page for a given
36
+ * error.
37
+ */
24
38
  export type StatusPageRenderer = (error: HttpError, ctx: HttpContext) => any | Promise<any>;
39
+ /**
40
+ * Data type for the "http:request_finished" event
41
+ */
25
42
  export type HttpRequestFinishedPayload = {
26
43
  ctx: HttpContext;
27
44
  duration: [number, number];
28
45
  };
46
+ /**
47
+ * Error handler to handle HTTP errors
48
+ */
29
49
  export type ServerErrorHandler = {
30
50
  report: (error: any, ctx: HttpContext) => any;
31
51
  handle: (error: any, ctx: HttpContext) => any;
32
52
  };
53
+ /**
54
+ * Error handler represented as a class
55
+ */
33
56
  export type ErrorHandlerAsAClass = Constructor<ServerErrorHandler>;
57
+ /**
58
+ * Config accepted by the HTTP server
59
+ */
34
60
  export type ServerConfig = RequestConfig & ResponseConfig & {
61
+ /**
62
+ * Whether or not to create an async local storage store for
63
+ * the HTTP context.
64
+ *
65
+ * Defaults to false
66
+ */
35
67
  useAsyncLocalStorage: boolean;
68
+ /**
69
+ * Config for query string parser
70
+ */
36
71
  qs: QSParserConfig;
37
72
  };
38
- //# sourceMappingURL=server.d.ts.map
@@ -1 +1,9 @@
1
+ /*
2
+ * @adonisjs/http-server
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
1
9
  export {};
package/package.json CHANGED
@@ -1,17 +1,13 @@
1
1
  {
2
2
  "name": "@adonisjs/http-server",
3
- "version": "6.8.2-5",
3
+ "version": "6.8.2-7",
4
4
  "description": "AdonisJS HTTP server with support packed with Routing and Cookies",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
7
7
  "files": [
8
- "src",
9
- "factories",
10
- "index.ts",
11
8
  "build/src",
12
9
  "build/factories",
13
10
  "build/index.d.ts",
14
- "build/index.d.ts.map",
15
11
  "build/index.js"
16
12
  ],
17
13
  "exports": {
@@ -19,10 +15,14 @@
19
15
  "./types": "./build/src/types/main.js",
20
16
  "./factories": "./build/factories/main.js"
21
17
  },
18
+ "engines": {
19
+ "node": ">=18.16.0"
20
+ },
22
21
  "scripts": {
23
22
  "pretest": "npm run lint",
24
- "test": "cross-env NODE_DEBUG=adonisjs:http c8 npm run vscode:test",
23
+ "test": "cross-env NODE_DEBUG=adonisjs:http c8 npm run quick:test",
25
24
  "clean": "del-cli build",
25
+ "typecheck": "tsc --noEmit",
26
26
  "compile": "npm run lint && npm run clean && tsc",
27
27
  "build": "npm run compile",
28
28
  "prebenchmark": "npm run build",
@@ -34,7 +34,7 @@
34
34
  "lint": "eslint . --ext=.ts",
35
35
  "sync-labels": "github-label-sync --labels .github/labels.json adonisjs/http-server",
36
36
  "test:watch": "node --watch --loader=ts-node/esm --experimental-import-meta-resolve bin/test.ts",
37
- "vscode:test": "node --loader=ts-node/esm --experimental-import-meta-resolve bin/test.ts"
37
+ "quick:test": "node --loader=ts-node/esm --experimental-import-meta-resolve bin/test.ts"
38
38
  },
39
39
  "keywords": [
40
40
  "http",
@@ -43,20 +43,22 @@
43
43
  "author": "virk,adonisjs",
44
44
  "license": "MIT",
45
45
  "devDependencies": {
46
- "@adonisjs/application": "^7.1.2-3",
47
- "@adonisjs/encryption": "^5.1.2-1",
48
- "@adonisjs/events": "^8.4.9-2",
49
- "@adonisjs/fold": "^9.9.3-4",
50
- "@adonisjs/logger": "^5.4.2-1",
51
- "@commitlint/cli": "^17.5.0",
52
- "@commitlint/config-conventional": "^17.4.4",
53
- "@fastify/middie": "^8.1.0",
54
- "@japa/assert": "^1.4.1",
55
- "@japa/expect-type": "^1.0.3",
56
- "@japa/run-failed-tests": "^1.1.1",
57
- "@japa/runner": "^2.5.1",
58
- "@japa/spec-reporter": "^1.3.3",
59
- "@swc/core": "^1.3.42",
46
+ "@adonisjs/application": "^7.1.2-6",
47
+ "@adonisjs/encryption": "^5.1.2-2",
48
+ "@adonisjs/eslint-config": "^1.1.7",
49
+ "@adonisjs/events": "^8.4.9-3",
50
+ "@adonisjs/fold": "^9.9.3-5",
51
+ "@adonisjs/logger": "^5.4.2-3",
52
+ "@adonisjs/prettier-config": "^1.1.7",
53
+ "@adonisjs/tsconfig": "^1.1.7",
54
+ "@commitlint/cli": "^17.6.6",
55
+ "@commitlint/config-conventional": "^17.6.6",
56
+ "@fastify/middie": "^8.3.0",
57
+ "@japa/api-client": "^2.0.0-0",
58
+ "@japa/assert": "^2.0.0-1",
59
+ "@japa/expect-type": "^2.0.0-0",
60
+ "@japa/runner": "^3.0.0-3",
61
+ "@swc/core": "^1.3.67",
60
62
  "@types/accepts": "^1.3.5",
61
63
  "@types/content-disposition": "^0.5.5",
62
64
  "@types/cookie": "^0.5.1",
@@ -67,7 +69,7 @@
67
69
  "@types/fs-extra": "^11.0.1",
68
70
  "@types/http-status-codes": "^1.2.0",
69
71
  "@types/mime-types": "^2.1.1",
70
- "@types/node": "^18.15.10",
72
+ "@types/node": "^20.3.3",
71
73
  "@types/on-finished": "^2.3.1",
72
74
  "@types/pem": "^1.9.6",
73
75
  "@types/proxy-addr": "^2.0.0",
@@ -75,33 +77,31 @@
75
77
  "@types/supertest": "^2.0.12",
76
78
  "@types/type-is": "^1.6.3",
77
79
  "@types/vary": "^1.1.0",
78
- "autocannon": "^7.10.0",
79
- "c8": "^7.13.0",
80
+ "autocannon": "^7.11.0",
81
+ "c8": "^8.0.0",
80
82
  "cross-env": "^7.0.3",
81
83
  "del-cli": "^5.0.0",
82
- "eslint": "^8.36.0",
83
- "eslint-config-prettier": "^8.8.0",
84
- "eslint-plugin-adonis": "^3.0.3",
85
- "eslint-plugin-prettier": "^4.2.1",
86
- "fastify": "^4.15.0",
84
+ "eslint": "^8.44.0",
85
+ "fastify": "^4.19.1",
87
86
  "fs-extra": "^11.1.1",
87
+ "get-port": "^7.0.0",
88
88
  "github-label-sync": "^2.3.1",
89
89
  "http-status-codes": "^2.2.0",
90
90
  "husky": "^8.0.3",
91
- "np": "^7.6.4",
92
- "pem": "^1.14.6",
93
- "prettier": "^2.8.7",
91
+ "np": "^8.0.4",
92
+ "pem": "^1.14.8",
93
+ "prettier": "^2.8.8",
94
94
  "reflect-metadata": "^0.1.13",
95
95
  "supertest": "^6.3.3",
96
96
  "ts-node": "^10.9.1",
97
- "typescript": "^5.0.2"
97
+ "typescript": "^5.1.6"
98
98
  },
99
99
  "dependencies": {
100
- "@paralleldrive/cuid2": "^2.2.0",
101
- "@poppinss/macroable": "^1.0.0-4",
100
+ "@paralleldrive/cuid2": "^2.2.1",
101
+ "@poppinss/macroable": "^1.0.0-7",
102
102
  "@poppinss/matchit": "^3.1.2",
103
- "@poppinss/middleware": "^3.1.2",
104
- "@poppinss/utils": "^6.5.0-2",
103
+ "@poppinss/middleware": "^3.1.3",
104
+ "@poppinss/utils": "^6.5.0-3",
105
105
  "@sindresorhus/is": "^5.3.0",
106
106
  "accepts": "^1.3.8",
107
107
  "content-disposition": "^0.5.4",
@@ -113,7 +113,7 @@
113
113
  "mime-types": "^2.1.35",
114
114
  "on-finished": "^2.4.1",
115
115
  "proxy-addr": "^2.0.7",
116
- "qs": "^6.11.1",
116
+ "qs": "^6.11.2",
117
117
  "tmp-cache": "^1.1.0",
118
118
  "type-is": "^1.6.18",
119
119
  "vary": "^1.1.2",
@@ -134,37 +134,6 @@
134
134
  "url": "https://github.com/adonisjs/http-server/issues"
135
135
  },
136
136
  "homepage": "https://github.com/adonisjs/http-server#readme",
137
- "eslintConfig": {
138
- "extends": [
139
- "plugin:adonis/typescriptPackage",
140
- "prettier"
141
- ],
142
- "plugins": [
143
- "prettier"
144
- ],
145
- "rules": {
146
- "prettier/prettier": [
147
- "error",
148
- {
149
- "endOfLine": "auto"
150
- }
151
- ]
152
- }
153
- },
154
- "eslintIgnore": [
155
- "build",
156
- "backup"
157
- ],
158
- "prettier": {
159
- "trailingComma": "es5",
160
- "semi": false,
161
- "singleQuote": true,
162
- "useTabs": false,
163
- "quoteProps": "consistent",
164
- "bracketSpacing": true,
165
- "arrowParens": "always",
166
- "printWidth": 100
167
- },
168
137
  "commitlint": {
169
138
  "extends": [
170
139
  "@commitlint/config-conventional"
@@ -190,5 +159,9 @@
190
159
  "factories/**",
191
160
  ".yalc/**"
192
161
  ]
193
- }
162
+ },
163
+ "eslintConfig": {
164
+ "extends": "@adonisjs/eslint-config/package"
165
+ },
166
+ "prettier": "@adonisjs/prettier-config"
194
167
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"http_context.d.ts","sourceRoot":"","sources":["../../factories/http_context.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAK9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,QAAQ,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAMD,qBAAa,kBAAkB;;IA2B7B,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC;IAQxC,MAAM;CAQP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../factories/main.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"qs_parser_factory.d.ts","sourceRoot":"","sources":["../../factories/qs_parser_factory.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAMxD,qBAAa,eAAe;;IAoB1B,KAAK,CACH,OAAO,EAAE,OAAO,CAAC;QACf,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;QACvC,SAAS,EAAE,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAA;KAChD,CAAC;IAUJ,MAAM;CAGP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../factories/request.ts"],"names":[],"mappings":";AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAG3D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAGvD,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,eAAe,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;CAC/B,CAAA;AAMD,qBAAa,cAAc;;IAkDzB,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC;IAQxC,MAAM;CAUP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../factories/response.ts"],"names":[],"mappings":";AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAI3D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAGzD,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,eAAe,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC/B,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAMD,qBAAa,eAAe;;IAqD1B,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC;IAQxC,MAAM;CAYP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../factories/router.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAIxD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAG9C,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,CAAA;IACrB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAMD,qBAAa,aAAa;;IAuBxB,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC;IAQxC,MAAM;CAGP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"server_factory.d.ts","sourceRoot":"","sources":["../../factories/server_factory.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAIxD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAE1D,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACrB,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;CAC9B,CAAA;AAMD,qBAAa,aAAa;;IA4CxB,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC;IAQxC,MAAM;CASP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/cookies/client.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAUtD,qBAAa,YAAY;;gBAGX,UAAU,EAAE,UAAU;IAOlC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI;IAO/C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI;IAO5C,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI;IAO5C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IASjC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IASlC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAO/B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;CAsB9B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"encrypted.d.ts","sourceRoot":"","sources":["../../../../src/cookies/drivers/encrypted.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAKtD,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,MAAM,CAKnF;AAMD,wBAAgB,SAAS,CAAC,cAAc,EAAE,MAAM,WAE/C;AAOD,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,GAAG,CAO9F"}