@adonisjs/http-server 6.6.3-0 → 6.7.0-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.
package/build/index.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ export { defineConfig } from './src/define_config.js';
|
|
|
11
11
|
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
|
-
export {
|
|
14
|
+
export { ExceptionHandler } from './src/exception_handler.js';
|
package/build/index.js
CHANGED
|
@@ -11,4 +11,4 @@ export { defineConfig } from './src/define_config.js';
|
|
|
11
11
|
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
|
-
export {
|
|
14
|
+
export { ExceptionHandler } from './src/exception_handler.js';
|
|
@@ -2,7 +2,7 @@ import type { Logger } from '@adonisjs/logger';
|
|
|
2
2
|
import type { Level } from '@adonisjs/logger/types';
|
|
3
3
|
import type { HttpContext } from './http_context/main.js';
|
|
4
4
|
import type { HttpError, StatusPageRange, StatusPageRenderer } from './types/server.js';
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class ExceptionHandler {
|
|
6
6
|
#private;
|
|
7
7
|
protected logger: Logger;
|
|
8
8
|
protected debug: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import is from '@sindresorhus/is';
|
|
2
2
|
import { parseRange } from './helpers.js';
|
|
3
3
|
import * as errors from './exceptions.js';
|
|
4
|
-
export class
|
|
4
|
+
export class ExceptionHandler {
|
|
5
5
|
logger;
|
|
6
6
|
debug = process.env.NODE_ENV !== 'production';
|
|
7
7
|
renderStatusPages = process.env.NODE_ENV === 'production';
|
|
@@ -5,11 +5,15 @@ import type { Logger } from '@adonisjs/logger';
|
|
|
5
5
|
import type { Encryption } from '@adonisjs/encryption';
|
|
6
6
|
import type { Server as HttpsServer } from 'node:https';
|
|
7
7
|
import type { Application } from '@adonisjs/application';
|
|
8
|
+
import { ContainerResolver } from '@adonisjs/fold';
|
|
8
9
|
import type { ServerResponse, IncomingMessage, Server as HttpServer } from 'node:http';
|
|
9
10
|
import type { LazyImport } from '../types/base.js';
|
|
10
11
|
import type { MiddlewareAsClass } from '../types/middleware.js';
|
|
11
12
|
import type { ErrorHandlerAsAClass, ServerConfig } from '../types/server.js';
|
|
13
|
+
import { Request } from '../request.js';
|
|
14
|
+
import { Response } from '../response.js';
|
|
12
15
|
import { Router } from '../router/main.js';
|
|
16
|
+
import { HttpContext } from '../http_context/main.js';
|
|
13
17
|
export declare class Server {
|
|
14
18
|
#private;
|
|
15
19
|
get usingAsyncLocalStorage(): boolean;
|
|
@@ -20,5 +24,8 @@ export declare class Server {
|
|
|
20
24
|
setNodeServer(server: HttpServer | HttpsServer): void;
|
|
21
25
|
getNodeServer(): HttpServer<typeof IncomingMessage, typeof ServerResponse> | HttpsServer<typeof IncomingMessage, typeof ServerResponse> | undefined;
|
|
22
26
|
getRouter(): Router;
|
|
27
|
+
createRequest(req: IncomingMessage, res: ServerResponse): Request;
|
|
28
|
+
createResponse(req: IncomingMessage, res: ServerResponse): Response;
|
|
29
|
+
createHttpContext(request: Request, response: Response, resolver: ContainerResolver<any>): HttpContext;
|
|
23
30
|
handle(req: IncomingMessage, res: ServerResponse): Promise<any>;
|
|
24
31
|
}
|
package/build/src/server/main.js
CHANGED
|
@@ -102,13 +102,20 @@ export class Server {
|
|
|
102
102
|
getRouter() {
|
|
103
103
|
return this.#router;
|
|
104
104
|
}
|
|
105
|
+
createRequest(req, res) {
|
|
106
|
+
return new Request(req, res, this.#encryption, this.#config, this.#qsParser);
|
|
107
|
+
}
|
|
108
|
+
createResponse(req, res) {
|
|
109
|
+
return new Response(req, res, this.#encryption, this.#config, this.#router, this.#qsParser);
|
|
110
|
+
}
|
|
111
|
+
createHttpContext(request, response, resolver) {
|
|
112
|
+
return new HttpContext(request, response, this.#logger.child({ request_id: request.id() }), resolver);
|
|
113
|
+
}
|
|
105
114
|
handle(req, res) {
|
|
106
115
|
const hasRequestListener = this.#emitter.hasListeners('http:request_finished');
|
|
107
116
|
const startTime = hasRequestListener ? process.hrtime() : null;
|
|
108
117
|
const resolver = this.#app.container.createResolver();
|
|
109
|
-
const
|
|
110
|
-
const response = new Response(req, res, this.#encryption, this.#config, this.#router, this.#qsParser);
|
|
111
|
-
const ctx = new HttpContext(request, response, this.#logger.child({ request_id: request.id() }), resolver);
|
|
118
|
+
const ctx = this.createHttpContext(this.createRequest(req, res), this.createResponse(req, res), resolver);
|
|
112
119
|
if (startTime) {
|
|
113
120
|
onFinished(res, () => {
|
|
114
121
|
this.#emitter.emit('http:request_finished', {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/http-server",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.0-0",
|
|
4
4
|
"description": "AdonisJS HTTP server with support packed with Routing and Cookies",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
"@commitlint/cli": "^17.4.2",
|
|
49
49
|
"@commitlint/config-conventional": "^17.4.2",
|
|
50
50
|
"@fastify/middie": "^8.1.0",
|
|
51
|
-
"@japa/api-client": "^1.4.
|
|
52
|
-
"@japa/assert": "^1.
|
|
53
|
-
"@japa/expect-type": "^1.0.
|
|
54
|
-
"@japa/run-failed-tests": "^1.1.
|
|
55
|
-
"@japa/runner": "^2.
|
|
56
|
-
"@japa/spec-reporter": "^1.3.
|
|
57
|
-
"@swc/core": "^1.3.
|
|
51
|
+
"@japa/api-client": "^1.4.3",
|
|
52
|
+
"@japa/assert": "^1.4.1",
|
|
53
|
+
"@japa/expect-type": "^1.0.3",
|
|
54
|
+
"@japa/run-failed-tests": "^1.1.1",
|
|
55
|
+
"@japa/runner": "^2.3.0",
|
|
56
|
+
"@japa/spec-reporter": "^1.3.3",
|
|
57
|
+
"@swc/core": "^1.3.35",
|
|
58
58
|
"@types/accepts": "^1.3.5",
|
|
59
59
|
"@types/content-disposition": "^0.5.5",
|
|
60
60
|
"@types/cookie": "^0.5.1",
|
|
@@ -76,18 +76,18 @@
|
|
|
76
76
|
"c8": "^7.12.0",
|
|
77
77
|
"cross-env": "^7.0.3",
|
|
78
78
|
"del-cli": "^5.0.0",
|
|
79
|
-
"eslint": "^8.
|
|
79
|
+
"eslint": "^8.34.0",
|
|
80
80
|
"eslint-config-prettier": "^8.6.0",
|
|
81
81
|
"eslint-plugin-adonis": "^3.0.3",
|
|
82
82
|
"eslint-plugin-prettier": "^4.2.1",
|
|
83
|
-
"fastify": "^4.
|
|
83
|
+
"fastify": "^4.13.0",
|
|
84
84
|
"fs-extra": "^11.1.0",
|
|
85
85
|
"github-label-sync": "^2.2.0",
|
|
86
86
|
"http-status-codes": "^2.2.0",
|
|
87
87
|
"husky": "^8.0.3",
|
|
88
88
|
"np": "^7.6.3",
|
|
89
89
|
"pem": "^1.14.6",
|
|
90
|
-
"prettier": "^2.8.
|
|
90
|
+
"prettier": "^2.8.4",
|
|
91
91
|
"reflect-metadata": "^0.1.13",
|
|
92
92
|
"supertest": "^6.3.3",
|
|
93
93
|
"ts-node": "^10.9.1",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"tmp-cache": "^1.1.0",
|
|
115
115
|
"type-is": "^1.6.18",
|
|
116
116
|
"vary": "^1.1.2",
|
|
117
|
-
"youch": "^3.2.
|
|
117
|
+
"youch": "^3.2.3"
|
|
118
118
|
},
|
|
119
119
|
"peerDependencies": {
|
|
120
120
|
"@adonisjs/application": "^7.0.1-0",
|