@adonisjs/http-server 7.0.0-0 → 7.0.0-1

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 (107) hide show
  1. package/build/factories/http_context.d.ts +25 -0
  2. package/build/factories/http_context.js +51 -0
  3. package/build/factories/http_server.d.ts +8 -0
  4. package/build/factories/http_server.js +26 -0
  5. package/build/factories/main.d.ts +6 -149
  6. package/build/factories/main.js +14 -331
  7. package/build/factories/qs_parser_factory.d.ts +20 -0
  8. package/build/factories/qs_parser_factory.js +44 -0
  9. package/build/factories/request.d.ts +29 -0
  10. package/build/factories/request.js +73 -0
  11. package/build/factories/response.d.ts +29 -0
  12. package/build/factories/response.js +77 -0
  13. package/build/factories/router.d.ts +23 -0
  14. package/build/factories/router.js +45 -0
  15. package/build/factories/server_factory.d.ts +29 -0
  16. package/build/factories/server_factory.js +65 -0
  17. package/build/index.d.ts +14 -272
  18. package/build/index.js +22 -308
  19. package/build/src/cookies/client.d.ts +37 -0
  20. package/build/src/cookies/client.js +84 -0
  21. package/build/src/cookies/drivers/encrypted.d.ts +16 -0
  22. package/build/src/cookies/drivers/encrypted.js +36 -0
  23. package/build/src/cookies/drivers/plain.d.ts +15 -0
  24. package/build/src/cookies/drivers/plain.js +33 -0
  25. package/build/src/cookies/drivers/signed.d.ts +16 -0
  26. package/build/src/cookies/drivers/signed.js +36 -0
  27. package/build/src/cookies/parser.d.ts +37 -0
  28. package/build/src/cookies/parser.js +167 -0
  29. package/build/src/cookies/serializer.d.ts +33 -0
  30. package/build/src/cookies/serializer.js +79 -0
  31. package/build/src/debug.d.ts +3 -0
  32. package/build/src/debug.js +10 -0
  33. package/build/src/define_config.d.ts +9 -0
  34. package/build/src/define_config.js +68 -0
  35. package/build/src/define_middleware.d.ts +11 -0
  36. package/build/src/define_middleware.js +35 -0
  37. package/build/src/exception_handler.d.ts +113 -0
  38. package/build/src/exception_handler.js +306 -0
  39. package/build/src/exceptions.d.ts +84 -0
  40. package/build/src/exceptions.js +38 -0
  41. package/build/src/helpers.d.ts +23 -0
  42. package/build/src/helpers.js +105 -0
  43. package/build/src/http_context/local_storage.d.ts +12 -0
  44. package/build/src/http_context/local_storage.js +39 -0
  45. package/build/src/http_context/main.d.ts +58 -0
  46. package/build/src/http_context/main.js +105 -0
  47. package/build/src/qs.d.ts +11 -0
  48. package/build/src/qs.js +25 -0
  49. package/build/src/redirect.d.ts +42 -0
  50. package/build/src/redirect.js +140 -0
  51. package/build/src/request.d.ts +565 -0
  52. package/build/src/request.js +865 -0
  53. package/build/src/response.d.ts +620 -0
  54. package/build/src/response.js +1208 -0
  55. package/build/src/router/brisk.d.ts +42 -0
  56. package/build/src/router/brisk.js +85 -0
  57. package/build/src/router/executor.d.ts +9 -0
  58. package/build/src/router/executor.js +30 -0
  59. package/build/src/router/factories/use_return_value.d.ts +6 -0
  60. package/build/src/router/factories/use_return_value.js +22 -0
  61. package/build/src/router/group.d.ts +65 -0
  62. package/build/src/router/group.js +207 -0
  63. package/build/src/router/lookup_store/main.d.ts +49 -0
  64. package/build/src/router/lookup_store/main.js +86 -0
  65. package/build/src/router/lookup_store/route_finder.d.ts +21 -0
  66. package/build/src/router/lookup_store/route_finder.js +49 -0
  67. package/build/src/router/lookup_store/url_builder.d.ts +52 -0
  68. package/build/src/router/lookup_store/url_builder.js +209 -0
  69. package/build/src/router/main.d.ts +128 -0
  70. package/build/src/router/main.js +316 -0
  71. package/build/src/router/matchers.d.ts +27 -0
  72. package/build/src/router/matchers.js +36 -0
  73. package/build/src/router/parser.d.ts +5 -0
  74. package/build/src/router/parser.js +17 -0
  75. package/build/src/router/resource.d.ts +54 -0
  76. package/build/src/router/resource.js +216 -0
  77. package/build/src/router/route.d.ts +92 -0
  78. package/build/src/router/route.js +293 -0
  79. package/build/src/router/store.d.ts +66 -0
  80. package/build/src/router/store.js +195 -0
  81. package/build/src/server/factories/final_handler.d.ts +10 -0
  82. package/build/src/server/factories/final_handler.js +30 -0
  83. package/build/src/server/factories/middleware_handler.d.ts +8 -0
  84. package/build/src/server/factories/middleware_handler.js +16 -0
  85. package/build/src/server/factories/write_response.d.ts +6 -0
  86. package/build/src/server/factories/write_response.js +24 -0
  87. package/build/{main-29eaaee4.d.ts → src/server/main.d.ts} +18 -13
  88. package/build/src/server/main.js +292 -0
  89. package/build/src/types/base.d.ts +19 -0
  90. package/build/src/types/base.js +9 -0
  91. package/build/src/types/main.d.ts +7 -14
  92. package/build/src/types/main.js +15 -0
  93. package/build/src/types/middleware.d.ts +35 -0
  94. package/build/src/types/middleware.js +9 -0
  95. package/build/src/types/qs.d.ts +68 -0
  96. package/build/src/types/qs.js +9 -0
  97. package/build/src/types/request.d.ts +39 -0
  98. package/build/src/types/request.js +9 -0
  99. package/build/src/types/response.d.ts +45 -0
  100. package/build/src/types/response.js +9 -0
  101. package/build/src/types/route.d.ts +166 -0
  102. package/build/src/types/route.js +9 -0
  103. package/build/src/types/server.d.ts +72 -0
  104. package/build/src/types/server.js +9 -0
  105. package/package.json +6 -3
  106. package/build/chunk-XX72ATFY.js +0 -4388
  107. package/build/main-e5b46c83.d.ts +0 -2210
@@ -0,0 +1,166 @@
1
+ import type Middleware from '@poppinss/middleware';
2
+ import type { ContainerResolver } from '@adonisjs/fold';
3
+ import type { Constructor, LazyImport } from './base.js';
4
+ import type { HttpContext } from '../http_context/main.js';
5
+ import type { MiddlewareFn, ParsedGlobalMiddleware } from './middleware.js';
6
+ import { ServerErrorHandler } from './server.js';
7
+ /**
8
+ * Returns a union of methods from a controller that accepts
9
+ * the context as the first argument.
10
+ */
11
+ export type GetControllerHandlers<Controller extends Constructor<any>> = {
12
+ [K in keyof InstanceType<Controller>]: InstanceType<Controller>[K] extends (ctx: HttpContext, ...args: any[]) => any ? K : never;
13
+ }[keyof InstanceType<Controller>];
14
+ /**
15
+ * Route token stored by matchit library
16
+ */
17
+ export type MatchItRouteToken = RouteMatcher & {
18
+ old: string;
19
+ type: 0 | 1 | 2 | 3;
20
+ val: string;
21
+ end: string;
22
+ };
23
+ /**
24
+ * Route handler defined as a function
25
+ */
26
+ export type RouteFn = (ctx: HttpContext) => any;
27
+ /**
28
+ * Route handler persisted with the route store
29
+ */
30
+ export type StoreRouteHandler = RouteFn | {
31
+ reference: string | [LazyImport<Constructor<any>> | Constructor<any>, any?];
32
+ handle: (resolver: ContainerResolver<any>, ...args: [ctx: HttpContext, ...injections: any[]]) => any;
33
+ };
34
+ /**
35
+ * The middleware persisted with the route store
36
+ */
37
+ export type StoreRouteMiddleware = MiddlewareFn | ({
38
+ name?: string;
39
+ args?: any[];
40
+ } & ParsedGlobalMiddleware);
41
+ /**
42
+ * Route node persisted within the routes store
43
+ */
44
+ export type StoreRouteNode = {
45
+ /**
46
+ * The execute function to execute the route middleware
47
+ * and the handler
48
+ */
49
+ execute: (route: StoreRouteNode, resolver: ContainerResolver<any>, ctx: HttpContext, errorResponder: ServerErrorHandler['handle']) => any;
50
+ /**
51
+ * A unique name for the route
52
+ */
53
+ name?: string;
54
+ /**
55
+ * Route URI pattern
56
+ */
57
+ pattern: string;
58
+ /**
59
+ * Route handler
60
+ */
61
+ handler: StoreRouteHandler;
62
+ /**
63
+ * Route middleware
64
+ */
65
+ middleware: Middleware<StoreRouteMiddleware>;
66
+ /**
67
+ * Additional metadata associated with the route
68
+ */
69
+ meta: Record<string, any>;
70
+ };
71
+ /**
72
+ * An object of routes for a given HTTP method
73
+ */
74
+ export type StoreMethodNode = {
75
+ tokens: MatchItRouteToken[][];
76
+ routeKeys: {
77
+ [pattern: string]: string;
78
+ };
79
+ routes: {
80
+ [pattern: string]: StoreRouteNode;
81
+ };
82
+ };
83
+ /**
84
+ * Each domain node container an object of methods. Each method
85
+ * object has nested routes.
86
+ */
87
+ export type StoreDomainNode = {
88
+ [method: string]: StoreMethodNode;
89
+ };
90
+ /**
91
+ * Routes tree stored within the routes store
92
+ */
93
+ export type StoreRoutesTree = {
94
+ tokens: MatchItRouteToken[][];
95
+ domains: {
96
+ [domain: string]: StoreDomainNode;
97
+ };
98
+ };
99
+ /**
100
+ * Shape of the matched route for a pattern, method and domain.
101
+ */
102
+ export type MatchedRoute = {
103
+ route: StoreRouteNode;
104
+ /**
105
+ * A unique key for the looked up route
106
+ */
107
+ routeKey: string;
108
+ /**
109
+ * Route params
110
+ */
111
+ params: Record<string, any>;
112
+ /**
113
+ * Route subdomains (if part of a subdomain)
114
+ */
115
+ subdomains: Record<string, any>;
116
+ };
117
+ /**
118
+ * Shape of a route param matcher
119
+ */
120
+ export type RouteMatcher = {
121
+ match?: RegExp;
122
+ cast?: (value: string) => any;
123
+ };
124
+ /**
125
+ * A collection of route matchers
126
+ */
127
+ export type RouteMatchers = {
128
+ [param: string]: RouteMatcher;
129
+ };
130
+ /**
131
+ * Representation of a route as JSON
132
+ */
133
+ export type RouteJSON = StoreRouteNode & {
134
+ /**
135
+ * HTTP methods, the route responds to.
136
+ */
137
+ methods: string[];
138
+ /**
139
+ * The domain for which the route is registered.
140
+ */
141
+ domain: string;
142
+ /**
143
+ * Matchers for route params.
144
+ */
145
+ matchers: RouteMatchers;
146
+ };
147
+ /**
148
+ * Resource action names
149
+ */
150
+ export type ResourceActionNames = 'create' | 'index' | 'store' | 'show' | 'edit' | 'update' | 'destroy';
151
+ /**
152
+ * Options accepted by makeUrl method
153
+ */
154
+ export type MakeUrlOptions = {
155
+ qs?: Record<string, any>;
156
+ domain?: string;
157
+ prefixUrl?: string;
158
+ disableRouteLookup?: boolean;
159
+ };
160
+ /**
161
+ * Options accepted by makeSignedUrl method
162
+ */
163
+ export type MakeSignedUrlOptions = MakeUrlOptions & {
164
+ expiresIn?: string | number;
165
+ purpose?: string;
166
+ };
@@ -0,0 +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
+ */
9
+ export {};
@@ -0,0 +1,72 @@
1
+ import type { ErrorHandler, FinalHandler } from '@poppinss/middleware/types';
2
+ import type { Constructor } from './base.js';
3
+ import type { QSParserConfig } from './qs.js';
4
+ import type { RequestConfig } from './request.js';
5
+ import type { ResponseConfig } from './response.js';
6
+ import type { HttpContext } from '../http_context/main.js';
7
+ /**
8
+ * Normalized HTTP error used by the exception
9
+ * handler.
10
+ */
11
+ export type HttpError = {
12
+ message: string;
13
+ status: number;
14
+ code?: string;
15
+ stack?: string;
16
+ cause?: any;
17
+ messages?: any;
18
+ errors?: any;
19
+ handle?: (...args: any[]) => any;
20
+ report?: (...args: any[]) => any;
21
+ };
22
+ /**
23
+ * The pipeline for executing middleware during tests
24
+ */
25
+ export interface TestingMiddlewarePipeline {
26
+ finalHandler(handler: FinalHandler): this;
27
+ errorHandler(handler: ErrorHandler): this;
28
+ run(ctx: HttpContext): Promise<any>;
29
+ }
30
+ /**
31
+ * The expression to define a status page range
32
+ */
33
+ export type StatusPageRange = `${number}..${number}` | `${number}` | number;
34
+ /**
35
+ * The callback function to render status page for a given
36
+ * error.
37
+ */
38
+ export type StatusPageRenderer = (error: HttpError, ctx: HttpContext) => any | Promise<any>;
39
+ /**
40
+ * Data type for the "http:request_finished" event
41
+ */
42
+ export type HttpRequestFinishedPayload = {
43
+ ctx: HttpContext;
44
+ duration: [number, number];
45
+ };
46
+ /**
47
+ * Error handler to handle HTTP errors
48
+ */
49
+ export type ServerErrorHandler = {
50
+ report: (error: any, ctx: HttpContext) => any;
51
+ handle: (error: any, ctx: HttpContext) => any;
52
+ };
53
+ /**
54
+ * Error handler represented as a class
55
+ */
56
+ export type ErrorHandlerAsAClass = Constructor<ServerErrorHandler>;
57
+ /**
58
+ * Config accepted by the HTTP server
59
+ */
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
+ */
67
+ useAsyncLocalStorage: boolean;
68
+ /**
69
+ * Config for query string parser
70
+ */
71
+ qs: QSParserConfig;
72
+ };
@@ -0,0 +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
+ */
9
+ export {};
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@adonisjs/http-server",
3
- "version": "7.0.0-0",
3
+ "version": "7.0.0-1",
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
- "build"
8
+ "build/factories",
9
+ "build/src",
10
+ "build/index.d.ts",
11
+ "build/index.js"
9
12
  ],
10
13
  "exports": {
11
14
  ".": "./build/index.js",
@@ -20,7 +23,7 @@
20
23
  "test": "cross-env NODE_DEBUG=adonisjs:http c8 npm run quick:test",
21
24
  "clean": "del-cli build",
22
25
  "typecheck": "tsc --noEmit",
23
- "compile": "npm run lint && npm run clean && tsup-node",
26
+ "compile": "npm run lint && npm run clean && tsc",
24
27
  "build": "npm run compile",
25
28
  "prebenchmark": "npm run build",
26
29
  "benchmark": "node benchmarks/index.js",