@deepkit/http 1.0.18 → 1.0.19
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/CHANGELOG.md +12 -0
- package/dist/cjs/src/http.d.ts +2 -2
- package/dist/cjs/src/http.js +3 -6
- package/dist/cjs/src/http.js.map +1 -1
- package/dist/cjs/src/kernel.d.ts +2 -2
- package/dist/cjs/src/kernel.js +7 -14
- package/dist/cjs/src/kernel.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/src/http.d.ts +2 -2
- package/dist/esm/src/http.js +3 -6
- package/dist/esm/src/http.js.map +1 -1
- package/dist/esm/src/kernel.d.ts +2 -2
- package/dist/esm/src/kernel.js +8 -15
- package/dist/esm/src/kernel.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/src/http.ts +3 -4
- package/src/kernel.ts +8 -21
package/src/http.ts
CHANGED
|
@@ -541,7 +541,7 @@ export class HttpListener {
|
|
|
541
541
|
protected logger: LoggerInterface,
|
|
542
542
|
protected resultFormatter: HttpResultFormatter,
|
|
543
543
|
protected injector: Injector,
|
|
544
|
-
protected stopwatch
|
|
544
|
+
protected stopwatch: Stopwatch,
|
|
545
545
|
) {
|
|
546
546
|
this.setRouteConfig = injector.createSetter(RouteConfig, {name: 'http'});
|
|
547
547
|
}
|
|
@@ -690,7 +690,7 @@ export class HttpListener {
|
|
|
690
690
|
? getClassName(event.route.action.controller) + '.' + event.route.action.methodName
|
|
691
691
|
: event.route.action.fn.name;
|
|
692
692
|
|
|
693
|
-
const frame = this.stopwatch
|
|
693
|
+
const frame = this.stopwatch.start(stopWatchLabel, FrameCategory.httpController);
|
|
694
694
|
try {
|
|
695
695
|
let result: any;
|
|
696
696
|
if (event.route.action.type === 'controller') {
|
|
@@ -716,7 +716,6 @@ export class HttpListener {
|
|
|
716
716
|
responseEvent.controllerActionTime = Date.now() - start;
|
|
717
717
|
event.next('response', responseEvent);
|
|
718
718
|
} catch (error: any) {
|
|
719
|
-
if (frame) frame.end();
|
|
720
719
|
if (error instanceof HttpAccessDeniedError) {
|
|
721
720
|
event.next('accessDenied', new HttpAccessDeniedEvent(event.injectorContext, event.request, event.response, event.route, error));
|
|
722
721
|
} else {
|
|
@@ -725,7 +724,7 @@ export class HttpListener {
|
|
|
725
724
|
event.next('controllerError', errorEvent);
|
|
726
725
|
}
|
|
727
726
|
} finally {
|
|
728
|
-
|
|
727
|
+
frame.end();
|
|
729
728
|
}
|
|
730
729
|
}
|
|
731
730
|
|
package/src/kernel.ts
CHANGED
|
@@ -2,14 +2,7 @@ import { InjectorContext, Setter } from '@deepkit/injector';
|
|
|
2
2
|
import { HttpRouter } from './router.js';
|
|
3
3
|
import { EventDispatcher } from '@deepkit/event';
|
|
4
4
|
import { LoggerInterface } from '@deepkit/logger';
|
|
5
|
-
import {
|
|
6
|
-
HttpRequest,
|
|
7
|
-
HttpResponse,
|
|
8
|
-
incomingMessageToHttpRequest,
|
|
9
|
-
MemoryHttpResponse,
|
|
10
|
-
RequestBuilder,
|
|
11
|
-
serverResponseToHttpResponse,
|
|
12
|
-
} from './model.js';
|
|
5
|
+
import { HttpRequest, HttpResponse, incomingMessageToHttpRequest, MemoryHttpResponse, RequestBuilder, serverResponseToHttpResponse } from './model.js';
|
|
13
6
|
import { HttpError, HttpRequestEvent, HttpResultFormatter, httpWorkflow, JSONResponse } from './http.js';
|
|
14
7
|
import { FrameCategory, Stopwatch } from '@deepkit/stopwatch';
|
|
15
8
|
import { unlink } from 'fs';
|
|
@@ -43,7 +36,7 @@ export class HttpKernel {
|
|
|
43
36
|
protected eventDispatcher: EventDispatcher,
|
|
44
37
|
protected injectorContext: InjectorContext,
|
|
45
38
|
protected logger: LoggerInterface,
|
|
46
|
-
protected stopwatch
|
|
39
|
+
protected stopwatch: Stopwatch,
|
|
47
40
|
) {
|
|
48
41
|
this.setHttpRequest = injectorContext.setter(undefined, HttpRequest);
|
|
49
42
|
this.setHttpResponse = injectorContext.setter(undefined, HttpResponse);
|
|
@@ -112,16 +105,12 @@ export class HttpKernel {
|
|
|
112
105
|
|
|
113
106
|
req.throwErrorOnNotFound = options.throwOnNotFound || false;
|
|
114
107
|
|
|
115
|
-
const frame = this.stopwatch
|
|
116
|
-
const workflow = httpWorkflow.create('start', this.eventDispatcher,
|
|
108
|
+
const frame = this.stopwatch.start(req.method + ' ' + req.getUrl(), FrameCategory.http, true);
|
|
109
|
+
const workflow = httpWorkflow.create('start', this.eventDispatcher, this.stopwatch, httpInjectorContext);
|
|
117
110
|
|
|
118
111
|
try {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
await frame.run(() => workflow.apply('request', new HttpRequestEvent(httpInjectorContext, req, res)));
|
|
122
|
-
} else {
|
|
123
|
-
await workflow.apply('request', new HttpRequestEvent(httpInjectorContext, req, res));
|
|
124
|
-
}
|
|
112
|
+
frame.data({ url: req.getUrl(), method: req.getMethod(), clientIp: req.getRemoteAddress() });
|
|
113
|
+
await frame.run(() => workflow.apply('request', new HttpRequestEvent(httpInjectorContext, req, res)));
|
|
125
114
|
} catch (error: any) {
|
|
126
115
|
if (!res.headersSent) {
|
|
127
116
|
const resultFormatter = httpInjectorContext.get(HttpResultFormatter);
|
|
@@ -151,10 +140,8 @@ export class HttpKernel {
|
|
|
151
140
|
});
|
|
152
141
|
}
|
|
153
142
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
frame.end();
|
|
157
|
-
}
|
|
143
|
+
frame.data({ responseStatus: res.statusCode });
|
|
144
|
+
frame.end();
|
|
158
145
|
}
|
|
159
146
|
}
|
|
160
147
|
}
|