@adonisjs/http-server 6.8.2-6 → 6.8.2-8
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.
- package/README.md +3 -6
- package/build/factories/http_context.d.ts +10 -1
- package/build/factories/http_context.js +27 -0
- package/build/factories/http_server.d.ts +8 -0
- package/build/factories/http_server.js +26 -0
- package/build/factories/main.d.ts +0 -1
- package/build/factories/main.js +8 -0
- package/build/factories/qs_parser_factory.d.ts +10 -1
- package/build/factories/qs_parser_factory.js +18 -0
- package/build/factories/request.d.ts +10 -1
- package/build/factories/request.js +31 -0
- package/build/factories/response.d.ts +10 -1
- package/build/factories/response.js +34 -0
- package/build/factories/router.d.ts +10 -1
- package/build/factories/router.js +25 -0
- package/build/factories/server_factory.d.ts +10 -1
- package/build/factories/server_factory.js +34 -0
- package/build/index.d.ts +0 -1
- package/build/index.js +8 -0
- package/build/src/cookies/client.d.ts +25 -1
- package/build/src/cookies/client.js +42 -0
- package/build/src/cookies/drivers/encrypted.d.ts +12 -1
- package/build/src/cookies/drivers/encrypted.js +20 -0
- package/build/src/cookies/drivers/plain.d.ts +12 -1
- package/build/src/cookies/drivers/plain.js +20 -0
- package/build/src/cookies/drivers/signed.d.ts +12 -1
- package/build/src/cookies/drivers/signed.js +20 -0
- package/build/src/cookies/parser.d.ts +28 -1
- package/build/src/cookies/parser.js +98 -0
- package/build/src/cookies/serializer.d.ts +22 -1
- package/build/src/cookies/serializer.js +40 -0
- package/build/src/debug.d.ts +0 -1
- package/build/src/debug.js +8 -0
- package/build/src/define_config.d.ts +3 -1
- package/build/src/define_config.js +11 -0
- package/build/src/define_middleware.d.ts +5 -1
- package/build/src/define_middleware.js +18 -0
- package/build/src/exception_handler.d.ts +65 -1
- package/build/src/exception_handler.js +95 -0
- package/build/src/exceptions.d.ts +6 -1
- package/build/src/exceptions.js +11 -0
- package/build/src/helpers.d.ts +14 -1
- package/build/src/helpers.js +22 -0
- package/build/src/http_context/local_storage.d.ts +3 -1
- package/build/src/http_context/local_storage.js +25 -0
- package/build/src/http_context/main.d.ts +36 -1
- package/build/src/http_context/main.js +54 -0
- package/build/src/qs.d.ts +4 -1
- package/build/src/qs.js +12 -0
- package/build/src/redirect.d.ts +24 -1
- package/build/src/redirect.js +60 -0
- package/build/src/request.d.ts +466 -1
- package/build/src/request.js +542 -0
- package/build/src/response.d.ts +425 -2
- package/build/src/response.js +608 -7
- package/build/src/router/brisk.d.ts +22 -1
- package/build/src/router/brisk.js +42 -0
- package/build/src/router/executor.d.ts +4 -1
- package/build/src/router/executor.js +12 -0
- package/build/src/router/factories/use_return_value.d.ts +4 -1
- package/build/src/router/factories/use_return_value.js +16 -3
- package/build/src/router/group.d.ts +47 -1
- package/build/src/router/group.js +88 -0
- package/build/src/router/lookup_store/main.d.ts +32 -1
- package/build/src/router/lookup_store/main.js +49 -0
- package/build/src/router/lookup_store/route_finder.d.ts +13 -1
- package/build/src/router/lookup_store/route_finder.js +21 -0
- package/build/src/router/lookup_store/url_builder.d.ts +36 -1
- package/build/src/router/lookup_store/url_builder.js +97 -0
- package/build/src/router/main.d.ts +87 -1
- package/build/src/router/main.js +142 -0
- package/build/src/router/matchers.d.ts +13 -1
- package/build/src/router/matchers.js +21 -0
- package/build/src/router/parser.d.ts +3 -1
- package/build/src/router/parser.js +12 -0
- package/build/src/router/resource.d.ts +28 -1
- package/build/src/router/resource.js +90 -0
- package/build/src/router/route.d.ts +65 -1
- package/build/src/router/route.js +151 -2
- package/build/src/router/store.d.ts +54 -1
- package/build/src/router/store.js +107 -0
- package/build/src/server/factories/final_handler.d.ts +5 -1
- package/build/src/server/factories/final_handler.js +13 -0
- package/build/src/server/factories/middleware_handler.d.ts +3 -1
- package/build/src/server/factories/middleware_handler.js +11 -0
- package/build/src/server/factories/write_response.d.ts +4 -1
- package/build/src/server/factories/write_response.js +12 -0
- package/build/src/server/main.d.ts +48 -1
- package/build/src/server/main.js +128 -0
- package/build/src/types/base.d.ts +12 -1
- package/build/src/types/base.js +8 -0
- package/build/src/types/main.d.ts +0 -1
- package/build/src/types/main.js +8 -0
- package/build/src/types/middleware.d.ts +18 -1
- package/build/src/types/middleware.js +8 -0
- package/build/src/types/qs.d.ts +53 -1
- package/build/src/types/qs.js +8 -0
- package/build/src/types/request.d.ts +32 -1
- package/build/src/types/request.js +8 -0
- package/build/src/types/response.d.ts +27 -1
- package/build/src/types/response.js +8 -0
- package/build/src/types/route.d.ts +87 -1
- package/build/src/types/route.js +8 -0
- package/build/src/types/server.d.ts +35 -1
- package/build/src/types/server.js +8 -0
- package/package.json +44 -71
- package/build/factories/http_context.d.ts.map +0 -1
- package/build/factories/main.d.ts.map +0 -1
- package/build/factories/qs_parser_factory.d.ts.map +0 -1
- package/build/factories/request.d.ts.map +0 -1
- package/build/factories/response.d.ts.map +0 -1
- package/build/factories/router.d.ts.map +0 -1
- package/build/factories/server_factory.d.ts.map +0 -1
- package/build/index.d.ts.map +0 -1
- package/build/src/cookies/client.d.ts.map +0 -1
- package/build/src/cookies/drivers/encrypted.d.ts.map +0 -1
- package/build/src/cookies/drivers/plain.d.ts.map +0 -1
- package/build/src/cookies/drivers/signed.d.ts.map +0 -1
- package/build/src/cookies/parser.d.ts.map +0 -1
- package/build/src/cookies/serializer.d.ts.map +0 -1
- package/build/src/debug.d.ts.map +0 -1
- package/build/src/define_config.d.ts.map +0 -1
- package/build/src/define_middleware.d.ts.map +0 -1
- package/build/src/exception_handler.d.ts.map +0 -1
- package/build/src/exceptions.d.ts.map +0 -1
- package/build/src/helpers.d.ts.map +0 -1
- package/build/src/http_context/local_storage.d.ts.map +0 -1
- package/build/src/http_context/main.d.ts.map +0 -1
- package/build/src/qs.d.ts.map +0 -1
- package/build/src/redirect.d.ts.map +0 -1
- package/build/src/request.d.ts.map +0 -1
- package/build/src/response.d.ts.map +0 -1
- package/build/src/router/brisk.d.ts.map +0 -1
- package/build/src/router/executor.d.ts.map +0 -1
- package/build/src/router/factories/use_return_value.d.ts.map +0 -1
- package/build/src/router/group.d.ts.map +0 -1
- package/build/src/router/lookup_store/main.d.ts.map +0 -1
- package/build/src/router/lookup_store/route_finder.d.ts.map +0 -1
- package/build/src/router/lookup_store/url_builder.d.ts.map +0 -1
- package/build/src/router/main.d.ts.map +0 -1
- package/build/src/router/matchers.d.ts.map +0 -1
- package/build/src/router/parser.d.ts.map +0 -1
- package/build/src/router/resource.d.ts.map +0 -1
- package/build/src/router/route.d.ts.map +0 -1
- package/build/src/router/store.d.ts.map +0 -1
- package/build/src/server/factories/final_handler.d.ts.map +0 -1
- package/build/src/server/factories/middleware_handler.d.ts.map +0 -1
- package/build/src/server/factories/write_response.d.ts.map +0 -1
- package/build/src/server/main.d.ts.map +0 -1
- package/build/src/types/base.d.ts.map +0 -1
- package/build/src/types/main.d.ts.map +0 -1
- package/build/src/types/middleware.d.ts.map +0 -1
- package/build/src/types/qs.d.ts.map +0 -1
- package/build/src/types/request.d.ts.map +0 -1
- package/build/src/types/response.d.ts.map +0 -1
- package/build/src/types/route.d.ts.map +0 -1
- package/build/src/types/server.d.ts.map +0 -1
- package/factories/http_context.ts +0 -73
- package/factories/main.ts +0 -15
- package/factories/qs_parser_factory.ts +0 -54
- package/factories/request.ts +0 -101
- package/factories/response.ts +0 -106
- package/factories/router.ts +0 -61
- package/factories/server_factory.ts +0 -94
- package/index.ts +0 -23
- package/src/cookies/client.ts +0 -98
- package/src/cookies/drivers/encrypted.ts +0 -42
- package/src/cookies/drivers/plain.ts +0 -37
- package/src/cookies/drivers/signed.ts +0 -42
- package/src/cookies/parser.ts +0 -196
- package/src/cookies/serializer.ts +0 -98
- package/src/debug.ts +0 -11
- package/src/define_config.ts +0 -56
- package/src/define_middleware.ts +0 -61
- package/src/exception_handler.ts +0 -290
- package/src/exceptions.ts +0 -55
- package/src/helpers.ts +0 -108
- package/src/http_context/local_storage.ts +0 -50
- package/src/http_context/main.ts +0 -126
- package/src/qs.ts +0 -31
- package/src/redirect.ts +0 -181
- package/src/request.ts +0 -982
- package/src/response.ts +0 -1421
- package/src/router/brisk.ts +0 -113
- package/src/router/executor.ts +0 -36
- package/src/router/factories/use_return_value.ts +0 -26
- package/src/router/group.ts +0 -243
- package/src/router/lookup_store/main.ts +0 -102
- package/src/router/lookup_store/route_finder.ts +0 -60
- package/src/router/lookup_store/url_builder.ts +0 -250
- package/src/router/main.ts +0 -431
- package/src/router/matchers.ts +0 -40
- package/src/router/parser.ts +0 -20
- package/src/router/resource.ts +0 -277
- package/src/router/route.ts +0 -363
- package/src/router/store.ts +0 -239
- package/src/server/factories/final_handler.ts +0 -38
- package/src/server/factories/middleware_handler.ts +0 -23
- package/src/server/factories/write_response.ts +0 -26
- package/src/server/main.ts +0 -356
- package/src/types/base.ts +0 -30
- package/src/types/main.ts +0 -16
- package/src/types/middleware.ts +0 -59
- package/src/types/qs.ts +0 -85
- package/src/types/request.ts +0 -52
- package/src/types/response.ts +0 -57
- package/src/types/route.ts +0 -217
- package/src/types/server.ts +0 -92
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<br />
|
|
4
4
|
|
|
5
|
-
[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]
|
|
5
|
+
[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]
|
|
6
6
|
|
|
7
7
|
## Introduction
|
|
8
8
|
Implementation of HTTP server used by AdonisJS. The package ships with a powerful **Router**, **Middleware pipeline**, helpers to create plain and signed URL for registered routes and much more.
|
|
@@ -21,8 +21,8 @@ In order to ensure that the AdonisJS community is welcoming to all, please revie
|
|
|
21
21
|
## License
|
|
22
22
|
AdonisJS HTTP server is open-sourced software licensed under the [MIT license](LICENSE.md).
|
|
23
23
|
|
|
24
|
-
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/http-server/
|
|
25
|
-
[gh-workflow-url]: https://github.com/adonisjs/http-server/actions/workflows/
|
|
24
|
+
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/http-server/checks.yml?style=for-the-badge
|
|
25
|
+
[gh-workflow-url]: https://github.com/adonisjs/http-server/actions/workflows/checks.yml "Github action"
|
|
26
26
|
|
|
27
27
|
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
28
28
|
[typescript-url]: "typescript"
|
|
@@ -32,6 +32,3 @@ AdonisJS HTTP server is open-sourced software licensed under the [MIT license](L
|
|
|
32
32
|
|
|
33
33
|
[license-image]: https://img.shields.io/npm/l/@adonisjs/http-server?color=blueviolet&style=for-the-badge
|
|
34
34
|
[license-url]: LICENSE.md "license"
|
|
35
|
-
|
|
36
|
-
[synk-image]: https://img.shields.io/snyk/vulnerabilities/github/adonisjs/http-server?label=Synk%20Vulnerabilities&style=for-the-badge
|
|
37
|
-
[synk-url]: https://snyk.io/test/github/adonisjs/http-server?targetFile=package.json "synk"
|
|
@@ -7,10 +7,19 @@ type FactoryParameters = {
|
|
|
7
7
|
response: Response;
|
|
8
8
|
logger: Logger;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* HttpContext factory is used to generate Http context class instances for
|
|
12
|
+
* testing
|
|
13
|
+
*/
|
|
10
14
|
export declare class HttpContextFactory {
|
|
11
15
|
#private;
|
|
16
|
+
/**
|
|
17
|
+
* Merge factory params
|
|
18
|
+
*/
|
|
12
19
|
merge(params: Partial<FactoryParameters>): this;
|
|
20
|
+
/**
|
|
21
|
+
* Create request
|
|
22
|
+
*/
|
|
13
23
|
create(): HttpContext;
|
|
14
24
|
}
|
|
15
25
|
export {};
|
|
16
|
-
//# sourceMappingURL=http_context.d.ts.map
|
|
@@ -1,23 +1,50 @@
|
|
|
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
|
import { Container } from '@adonisjs/fold';
|
|
2
10
|
import { LoggerFactory } from '@adonisjs/logger/factories';
|
|
3
11
|
import { RequestFactory } from './request.js';
|
|
4
12
|
import { ResponseFactory } from './response.js';
|
|
5
13
|
import { HttpContext } from '../src/http_context/main.js';
|
|
14
|
+
/**
|
|
15
|
+
* HttpContext factory is used to generate Http context class instances for
|
|
16
|
+
* testing
|
|
17
|
+
*/
|
|
6
18
|
export class HttpContextFactory {
|
|
7
19
|
#parameters = {};
|
|
20
|
+
/**
|
|
21
|
+
* Returns the request class instance
|
|
22
|
+
*/
|
|
8
23
|
#createRequest() {
|
|
9
24
|
return this.#parameters.request || new RequestFactory().create();
|
|
10
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns the response class instance
|
|
28
|
+
*/
|
|
11
29
|
#createResponse() {
|
|
12
30
|
return this.#parameters.response || new ResponseFactory().create();
|
|
13
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns an instance of the logger class
|
|
34
|
+
*/
|
|
14
35
|
#createLogger() {
|
|
15
36
|
return this.#parameters.logger || new LoggerFactory().create();
|
|
16
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Merge factory params
|
|
40
|
+
*/
|
|
17
41
|
merge(params) {
|
|
18
42
|
Object.assign(this.#parameters, params);
|
|
19
43
|
return this;
|
|
20
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Create request
|
|
47
|
+
*/
|
|
21
48
|
create() {
|
|
22
49
|
return new HttpContext(this.#createRequest(), this.#createResponse(), this.#createLogger(), new Container().createResolver());
|
|
23
50
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
import getPort from 'get-port';
|
|
10
|
+
import { getActiveTest } from '@japa/runner';
|
|
11
|
+
import { createServer } from 'node:http';
|
|
12
|
+
export const httpServer = {
|
|
13
|
+
async create(handler) {
|
|
14
|
+
const server = createServer(handler);
|
|
15
|
+
const test = getActiveTest();
|
|
16
|
+
test?.cleanup(() => {
|
|
17
|
+
server.close();
|
|
18
|
+
});
|
|
19
|
+
const port = await getPort({ port: 3000 });
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
server.listen(port, 'localhost', () => {
|
|
22
|
+
return resolve({ server, port, url: `http://localhost:${port}` });
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
};
|
package/build/factories/main.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
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 { HttpContextFactory } from './http_context.js';
|
|
2
10
|
export { QsParserFactory } from './qs_parser_factory.js';
|
|
3
11
|
export { RequestFactory } from './request.js';
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { Qs } from '../src/qs.js';
|
|
2
2
|
import type { QSParserConfig } from '../src/types/qs.js';
|
|
3
|
+
/**
|
|
4
|
+
* QS Parser factory is used to generate the query string
|
|
5
|
+
* parser for testing
|
|
6
|
+
*/
|
|
3
7
|
export declare class QsParserFactory {
|
|
4
8
|
#private;
|
|
9
|
+
/**
|
|
10
|
+
* Merge encryption factory options
|
|
11
|
+
*/
|
|
5
12
|
merge(options: Partial<{
|
|
6
13
|
parse: Partial<QSParserConfig['parse']>;
|
|
7
14
|
stringify: Partial<QSParserConfig['stringify']>;
|
|
8
15
|
}>): this;
|
|
16
|
+
/**
|
|
17
|
+
* Create instance of the logger class
|
|
18
|
+
*/
|
|
9
19
|
create(): Qs;
|
|
10
20
|
}
|
|
11
|
-
//# sourceMappingURL=qs_parser_factory.d.ts.map
|
|
@@ -1,4 +1,16 @@
|
|
|
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
|
import { Qs } from '../src/qs.js';
|
|
10
|
+
/**
|
|
11
|
+
* QS Parser factory is used to generate the query string
|
|
12
|
+
* parser for testing
|
|
13
|
+
*/
|
|
2
14
|
export class QsParserFactory {
|
|
3
15
|
#options = {
|
|
4
16
|
parse: {
|
|
@@ -15,11 +27,17 @@ export class QsParserFactory {
|
|
|
15
27
|
skipNulls: false,
|
|
16
28
|
},
|
|
17
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* Merge encryption factory options
|
|
32
|
+
*/
|
|
18
33
|
merge(options) {
|
|
19
34
|
Object.assign(this.#options.parse, options.parse);
|
|
20
35
|
Object.assign(this.#options.stringify, options.stringify);
|
|
21
36
|
return this;
|
|
22
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Create instance of the logger class
|
|
40
|
+
*/
|
|
23
41
|
create() {
|
|
24
42
|
return new Qs(this.#options);
|
|
25
43
|
}
|
|
@@ -11,10 +11,19 @@ type FactoryParameters = {
|
|
|
11
11
|
encryption: Encryption;
|
|
12
12
|
config: Partial<RequestConfig>;
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Request factory is used to generate request class instances for
|
|
16
|
+
* testing
|
|
17
|
+
*/
|
|
14
18
|
export declare class RequestFactory {
|
|
15
19
|
#private;
|
|
20
|
+
/**
|
|
21
|
+
* Merge factory params
|
|
22
|
+
*/
|
|
16
23
|
merge(params: Partial<FactoryParameters>): this;
|
|
24
|
+
/**
|
|
25
|
+
* Create request
|
|
26
|
+
*/
|
|
17
27
|
create(): Request;
|
|
18
28
|
}
|
|
19
29
|
export {};
|
|
20
|
-
//# sourceMappingURL=request.d.ts.map
|
|
@@ -1,11 +1,26 @@
|
|
|
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
|
import { Socket } from 'node:net';
|
|
2
10
|
import proxyAddr from 'proxy-addr';
|
|
3
11
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
4
12
|
import { EncryptionFactory } from '@adonisjs/encryption/factories';
|
|
5
13
|
import { Request } from '../src/request.js';
|
|
6
14
|
import { QsParserFactory } from './qs_parser_factory.js';
|
|
15
|
+
/**
|
|
16
|
+
* Request factory is used to generate request class instances for
|
|
17
|
+
* testing
|
|
18
|
+
*/
|
|
7
19
|
export class RequestFactory {
|
|
8
20
|
#parameters = {};
|
|
21
|
+
/**
|
|
22
|
+
* Returns the config for the request class
|
|
23
|
+
*/
|
|
9
24
|
#getConfig() {
|
|
10
25
|
return {
|
|
11
26
|
allowMethodSpoofing: false,
|
|
@@ -15,6 +30,9 @@ export class RequestFactory {
|
|
|
15
30
|
...this.#parameters.config,
|
|
16
31
|
};
|
|
17
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns the HTTP req object
|
|
35
|
+
*/
|
|
18
36
|
#createRequest() {
|
|
19
37
|
const req = this.#parameters.req || new IncomingMessage(new Socket());
|
|
20
38
|
if (this.#parameters.url) {
|
|
@@ -25,16 +43,29 @@ export class RequestFactory {
|
|
|
25
43
|
}
|
|
26
44
|
return req;
|
|
27
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns the HTTP res object
|
|
48
|
+
*/
|
|
28
49
|
#createResponse(req) {
|
|
29
50
|
return this.#parameters.res || new ServerResponse(req);
|
|
30
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns an instance of the encryptor to encrypt
|
|
54
|
+
* signed URLs
|
|
55
|
+
*/
|
|
31
56
|
#createEncryption() {
|
|
32
57
|
return this.#parameters.encryption || new EncryptionFactory().create();
|
|
33
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Merge factory params
|
|
61
|
+
*/
|
|
34
62
|
merge(params) {
|
|
35
63
|
Object.assign(this.#parameters, params);
|
|
36
64
|
return this;
|
|
37
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Create request
|
|
68
|
+
*/
|
|
38
69
|
create() {
|
|
39
70
|
const req = this.#createRequest();
|
|
40
71
|
return new Request(req, this.#createResponse(req), this.#createEncryption(), this.#getConfig(), new QsParserFactory().create());
|
|
@@ -11,10 +11,19 @@ type FactoryParameters = {
|
|
|
11
11
|
config: Partial<ResponseConfig>;
|
|
12
12
|
router: Router;
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Response factory is used to generate response class instances for
|
|
16
|
+
* testing
|
|
17
|
+
*/
|
|
14
18
|
export declare class ResponseFactory {
|
|
15
19
|
#private;
|
|
20
|
+
/**
|
|
21
|
+
* Merge factory params
|
|
22
|
+
*/
|
|
16
23
|
merge(params: Partial<FactoryParameters>): this;
|
|
24
|
+
/**
|
|
25
|
+
* Create response class instance
|
|
26
|
+
*/
|
|
17
27
|
create(): Response;
|
|
18
28
|
}
|
|
19
29
|
export {};
|
|
20
|
-
//# sourceMappingURL=response.d.ts.map
|
|
@@ -1,11 +1,26 @@
|
|
|
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
|
import { Socket } from 'node:net';
|
|
2
10
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
11
|
import { EncryptionFactory } from '@adonisjs/encryption/factories';
|
|
4
12
|
import { RouterFactory } from './router.js';
|
|
5
13
|
import { Response } from '../src/response.js';
|
|
6
14
|
import { QsParserFactory } from './qs_parser_factory.js';
|
|
15
|
+
/**
|
|
16
|
+
* Response factory is used to generate response class instances for
|
|
17
|
+
* testing
|
|
18
|
+
*/
|
|
7
19
|
export class ResponseFactory {
|
|
8
20
|
#parameters = {};
|
|
21
|
+
/**
|
|
22
|
+
* Returns the config for the request class
|
|
23
|
+
*/
|
|
9
24
|
#getConfig() {
|
|
10
25
|
return {
|
|
11
26
|
etag: false,
|
|
@@ -20,22 +35,41 @@ export class ResponseFactory {
|
|
|
20
35
|
...this.#parameters.config,
|
|
21
36
|
};
|
|
22
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the HTTP req object
|
|
40
|
+
*/
|
|
23
41
|
#createRequest() {
|
|
24
42
|
return this.#parameters.req || new IncomingMessage(new Socket());
|
|
25
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns an instance of the router
|
|
46
|
+
*/
|
|
26
47
|
#createRouter() {
|
|
27
48
|
return this.#parameters.router || new RouterFactory().create();
|
|
28
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns the HTTP res object
|
|
52
|
+
*/
|
|
29
53
|
#createResponse(req) {
|
|
30
54
|
return this.#parameters.res || new ServerResponse(req);
|
|
31
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns an instance of the encryptor to encrypt
|
|
58
|
+
* signed URLs
|
|
59
|
+
*/
|
|
32
60
|
#createEncryption() {
|
|
33
61
|
return this.#parameters.encryption || new EncryptionFactory().create();
|
|
34
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Merge factory params
|
|
65
|
+
*/
|
|
35
66
|
merge(params) {
|
|
36
67
|
Object.assign(this.#parameters, params);
|
|
37
68
|
return this;
|
|
38
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Create response class instance
|
|
72
|
+
*/
|
|
39
73
|
create() {
|
|
40
74
|
const req = this.#createRequest();
|
|
41
75
|
return new Response(req, this.#createResponse(req), this.#createEncryption(), this.#getConfig(), this.#createRouter(), new QsParserFactory().create());
|
|
@@ -5,10 +5,19 @@ type FactoryParameters = {
|
|
|
5
5
|
app: Application<any>;
|
|
6
6
|
encryption: Encryption;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Router factory is used to generate router class instances for
|
|
10
|
+
* testing
|
|
11
|
+
*/
|
|
8
12
|
export declare class RouterFactory {
|
|
9
13
|
#private;
|
|
14
|
+
/**
|
|
15
|
+
* Merge factory params
|
|
16
|
+
*/
|
|
10
17
|
merge(params: Partial<FactoryParameters>): this;
|
|
18
|
+
/**
|
|
19
|
+
* Create router instance
|
|
20
|
+
*/
|
|
11
21
|
create(): Router;
|
|
12
22
|
}
|
|
13
23
|
export {};
|
|
14
|
-
//# sourceMappingURL=router.d.ts.map
|
|
@@ -1,19 +1,44 @@
|
|
|
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
|
import { AppFactory } from '@adonisjs/application/factories';
|
|
2
10
|
import { EncryptionFactory } from '@adonisjs/encryption/factories';
|
|
3
11
|
import { Router } from '../src/router/main.js';
|
|
4
12
|
import { QsParserFactory } from './qs_parser_factory.js';
|
|
13
|
+
/**
|
|
14
|
+
* Router factory is used to generate router class instances for
|
|
15
|
+
* testing
|
|
16
|
+
*/
|
|
5
17
|
export class RouterFactory {
|
|
6
18
|
#parameters = {};
|
|
19
|
+
/**
|
|
20
|
+
* Returns an instance of the application class
|
|
21
|
+
*/
|
|
7
22
|
#getApp() {
|
|
8
23
|
return (this.#parameters.app || new AppFactory().create(new URL('./app/', import.meta.url), () => { }));
|
|
9
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns an instance of the encryptor to encrypt
|
|
27
|
+
* signed URLs
|
|
28
|
+
*/
|
|
10
29
|
#createEncryption() {
|
|
11
30
|
return this.#parameters.encryption || new EncryptionFactory().create();
|
|
12
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Merge factory params
|
|
34
|
+
*/
|
|
13
35
|
merge(params) {
|
|
14
36
|
Object.assign(this.#parameters, params);
|
|
15
37
|
return this;
|
|
16
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Create router instance
|
|
41
|
+
*/
|
|
17
42
|
create() {
|
|
18
43
|
return new Router(this.#getApp(), this.#createEncryption(), new QsParserFactory().create());
|
|
19
44
|
}
|
|
@@ -11,10 +11,19 @@ type FactoryParameters = {
|
|
|
11
11
|
emitter: Emitter<any>;
|
|
12
12
|
config: Partial<ServerConfig>;
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Server factory is used to generate server class instances for
|
|
16
|
+
* testing
|
|
17
|
+
*/
|
|
14
18
|
export declare class ServerFactory {
|
|
15
19
|
#private;
|
|
20
|
+
/**
|
|
21
|
+
* Merge factory params
|
|
22
|
+
*/
|
|
16
23
|
merge(params: Partial<FactoryParameters>): this;
|
|
24
|
+
/**
|
|
25
|
+
* Create server instance
|
|
26
|
+
*/
|
|
17
27
|
create(): Server;
|
|
18
28
|
}
|
|
19
29
|
export {};
|
|
20
|
-
//# sourceMappingURL=server_factory.d.ts.map
|
|
@@ -1,30 +1,64 @@
|
|
|
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
|
import { Logger } from '@adonisjs/logger';
|
|
2
10
|
import { Emitter } from '@adonisjs/events';
|
|
3
11
|
import { AppFactory } from '@adonisjs/application/factories';
|
|
4
12
|
import { EncryptionFactory } from '@adonisjs/encryption/factories';
|
|
5
13
|
import { Server } from '../src/server/main.js';
|
|
6
14
|
import { defineConfig } from '../src/define_config.js';
|
|
15
|
+
/**
|
|
16
|
+
* Server factory is used to generate server class instances for
|
|
17
|
+
* testing
|
|
18
|
+
*/
|
|
7
19
|
export class ServerFactory {
|
|
8
20
|
#parameters = {};
|
|
21
|
+
/**
|
|
22
|
+
* Returns the emitter instance
|
|
23
|
+
*/
|
|
9
24
|
#getEmitter() {
|
|
10
25
|
return this.#parameters.emitter || new Emitter(this.#getApp());
|
|
11
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Returns the logger instance
|
|
29
|
+
*/
|
|
12
30
|
#getLogger() {
|
|
13
31
|
return this.#parameters.logger || new Logger({ enabled: false });
|
|
14
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns the config for the server class
|
|
35
|
+
*/
|
|
15
36
|
#getConfig() {
|
|
16
37
|
return defineConfig(this.#parameters.config || {});
|
|
17
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns an instance of the application class
|
|
41
|
+
*/
|
|
18
42
|
#getApp() {
|
|
19
43
|
return (this.#parameters.app || new AppFactory().create(new URL('./app/', import.meta.url), () => { }));
|
|
20
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns an instance of the encryptor to encrypt
|
|
47
|
+
* signed URLs
|
|
48
|
+
*/
|
|
21
49
|
#createEncryption() {
|
|
22
50
|
return this.#parameters.encryption || new EncryptionFactory().create();
|
|
23
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Merge factory params
|
|
54
|
+
*/
|
|
24
55
|
merge(params) {
|
|
25
56
|
Object.assign(this.#parameters, params);
|
|
26
57
|
return this;
|
|
27
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Create server instance
|
|
61
|
+
*/
|
|
28
62
|
create() {
|
|
29
63
|
return new Server(this.#getApp(), this.#createEncryption(), this.#getEmitter(), this.#getLogger(), this.#getConfig());
|
|
30
64
|
}
|
package/build/index.d.ts
CHANGED
|
@@ -12,4 +12,3 @@ export { CookieClient } from './src/cookies/client.js';
|
|
|
12
12
|
export { HttpContext } from './src/http_context/main.js';
|
|
13
13
|
export { RouteResource } from './src/router/resource.js';
|
|
14
14
|
export { ExceptionHandler } from './src/exception_handler.js';
|
|
15
|
-
//# sourceMappingURL=index.d.ts.map
|
package/build/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
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 { Request } from './src/request.js';
|
|
2
10
|
export { Response } from './src/response.js';
|
|
3
11
|
export { Redirect } from './src/redirect.js';
|
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
import type { Encryption } from '@adonisjs/encryption';
|
|
2
|
+
/**
|
|
3
|
+
* Cookie client exposes the API to parse/set AdonisJS cookies
|
|
4
|
+
* as a client.
|
|
5
|
+
*/
|
|
2
6
|
export declare class CookieClient {
|
|
3
7
|
#private;
|
|
4
8
|
constructor(encryption: Encryption);
|
|
9
|
+
/**
|
|
10
|
+
* Encrypt a key value pair to be sent in the cookie header
|
|
11
|
+
*/
|
|
5
12
|
encrypt(key: string, value: any): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Sign a key value pair to be sent in the cookie header
|
|
15
|
+
*/
|
|
6
16
|
sign(key: string, value: any): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Encode a key value pair to be sent in the cookie header
|
|
19
|
+
*/
|
|
7
20
|
encode(_: string, value: any): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Unsign a signed cookie value
|
|
23
|
+
*/
|
|
8
24
|
unsign(key: string, value: string): any;
|
|
25
|
+
/**
|
|
26
|
+
* Decrypt an encrypted cookie value
|
|
27
|
+
*/
|
|
9
28
|
decrypt(key: string, value: string): any;
|
|
29
|
+
/**
|
|
30
|
+
* Decode an encoded cookie value
|
|
31
|
+
*/
|
|
10
32
|
decode(_: string, value: string): any;
|
|
33
|
+
/**
|
|
34
|
+
* Parse response cookie
|
|
35
|
+
*/
|
|
11
36
|
parse(key: string, value: any): any;
|
|
12
37
|
}
|
|
13
|
-
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1,40 +1,82 @@
|
|
|
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
|
import * as plainCookiesDriver from './drivers/plain.js';
|
|
2
10
|
import * as signedCookiesDriver from './drivers/signed.js';
|
|
3
11
|
import * as encryptedCookiesDriver from './drivers/encrypted.js';
|
|
12
|
+
/**
|
|
13
|
+
* Cookie client exposes the API to parse/set AdonisJS cookies
|
|
14
|
+
* as a client.
|
|
15
|
+
*/
|
|
4
16
|
export class CookieClient {
|
|
5
17
|
#encryption;
|
|
6
18
|
constructor(encryption) {
|
|
7
19
|
this.#encryption = encryption;
|
|
8
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Encrypt a key value pair to be sent in the cookie header
|
|
23
|
+
*/
|
|
9
24
|
encrypt(key, value) {
|
|
10
25
|
return encryptedCookiesDriver.pack(key, value, this.#encryption);
|
|
11
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Sign a key value pair to be sent in the cookie header
|
|
29
|
+
*/
|
|
12
30
|
sign(key, value) {
|
|
13
31
|
return signedCookiesDriver.pack(key, value, this.#encryption);
|
|
14
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Encode a key value pair to be sent in the cookie header
|
|
35
|
+
*/
|
|
15
36
|
encode(_, value) {
|
|
16
37
|
return plainCookiesDriver.pack(value);
|
|
17
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Unsign a signed cookie value
|
|
41
|
+
*/
|
|
18
42
|
unsign(key, value) {
|
|
19
43
|
return signedCookiesDriver.canUnpack(value)
|
|
20
44
|
? signedCookiesDriver.unpack(key, value, this.#encryption)
|
|
21
45
|
: null;
|
|
22
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Decrypt an encrypted cookie value
|
|
49
|
+
*/
|
|
23
50
|
decrypt(key, value) {
|
|
24
51
|
return encryptedCookiesDriver.canUnpack(value)
|
|
25
52
|
? encryptedCookiesDriver.unpack(key, value, this.#encryption)
|
|
26
53
|
: null;
|
|
27
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Decode an encoded cookie value
|
|
57
|
+
*/
|
|
28
58
|
decode(_, value) {
|
|
29
59
|
return plainCookiesDriver.canUnpack(value) ? plainCookiesDriver.unpack(value) : null;
|
|
30
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Parse response cookie
|
|
63
|
+
*/
|
|
31
64
|
parse(key, value) {
|
|
65
|
+
/**
|
|
66
|
+
* Unsign signed cookie
|
|
67
|
+
*/
|
|
32
68
|
if (signedCookiesDriver.canUnpack(value)) {
|
|
33
69
|
return signedCookiesDriver.unpack(key, value, this.#encryption);
|
|
34
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Decrypted encrypted cookie
|
|
73
|
+
*/
|
|
35
74
|
if (encryptedCookiesDriver.canUnpack(value)) {
|
|
36
75
|
return encryptedCookiesDriver.unpack(key, value, this.#encryption);
|
|
37
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Decode encoded cookie
|
|
79
|
+
*/
|
|
38
80
|
if (plainCookiesDriver.canUnpack(value)) {
|
|
39
81
|
return plainCookiesDriver.unpack(value);
|
|
40
82
|
}
|