@rsdk/http.server.express 5.7.0-next.6 → 6.0.0-next.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.
- package/dist/express.log-formatter.d.ts +8 -0
- package/dist/express.log-formatter.js +32 -0
- package/dist/express.log-formatter.js.map +1 -0
- package/dist/{express.http-transport.d.ts → express.transport.d.ts} +2 -0
- package/dist/{express.http-transport.js → express.transport.js} +5 -1
- package/dist/express.transport.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/src/express.log-formatter.ts +43 -0
- package/src/{express.http-transport.ts → express.transport.ts} +7 -0
- package/src/index.ts +1 -1
- package/dist/express.http-transport.js.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import type { LogFormatter } from '@rsdk/core';
|
|
3
|
+
export declare class ExpressLogFormatter implements LogFormatter {
|
|
4
|
+
readonly protocol = "http";
|
|
5
|
+
getPath(context: ExecutionContext): string;
|
|
6
|
+
formatRequest(context: ExecutionContext, includeBody: boolean): Record<string, unknown>;
|
|
7
|
+
formatResponse(context: ExecutionContext, body: unknown | undefined): Record<string, unknown>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExpressLogFormatter = void 0;
|
|
4
|
+
class ExpressLogFormatter {
|
|
5
|
+
protocol = 'http';
|
|
6
|
+
getPath(context) {
|
|
7
|
+
const request = context.switchToHttp().getRequest();
|
|
8
|
+
// TODO: Может лучше голый путь - без query-параметров
|
|
9
|
+
return `${request.method} ${request.url}`;
|
|
10
|
+
}
|
|
11
|
+
formatRequest(context, includeBody) {
|
|
12
|
+
const request = context.switchToHttp().getRequest();
|
|
13
|
+
return {
|
|
14
|
+
query: request.query,
|
|
15
|
+
params: request.params,
|
|
16
|
+
method: request.method,
|
|
17
|
+
url: request.url,
|
|
18
|
+
headers: request.headers,
|
|
19
|
+
...(includeBody ? { body: request.body } : {}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
formatResponse(context, body) {
|
|
23
|
+
const res = context.switchToHttp().getResponse();
|
|
24
|
+
return {
|
|
25
|
+
statusCode: res.statusCode,
|
|
26
|
+
headers: res.getHeaders(),
|
|
27
|
+
body,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.ExpressLogFormatter = ExpressLogFormatter;
|
|
32
|
+
//# sourceMappingURL=express.log-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express.log-formatter.js","sourceRoot":"","sources":["../src/express.log-formatter.ts"],"names":[],"mappings":";;;AAIA,MAAa,mBAAmB;IACrB,QAAQ,GAAG,MAAM,CAAC;IAE3B,OAAO,CAAC,OAAyB;QAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAW,CAAC;QAE7D,sDAAsD;QACtD,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAC5C,CAAC;IAED,aAAa,CACX,OAAyB,EACzB,WAAoB;QAEpB,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAW,CAAC;QAE7D,OAAO;YACL,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/C,CAAC;IACJ,CAAC;IAED,cAAc,CACZ,OAAyB,EACzB,IAAyB;QAEzB,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,WAAW,EAAY,CAAC;QAE3D,OAAO;YACL,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,OAAO,EAAE,GAAG,CAAC,UAAU,EAAE;YACzB,IAAI;SACL,CAAC;IACJ,CAAC;CACF;AAtCD,kDAsCC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { AbstractHttpAdapter } from '@nestjs/core';
|
|
2
|
+
import type { LogFormatter } from '@rsdk/core';
|
|
2
3
|
import { AbstractHttpTransport } from '@rsdk/http.server';
|
|
3
4
|
import type { HttpConfig } from '@rsdk/http.server/dist/http.config';
|
|
4
5
|
export declare class ExpressHttpTransport extends AbstractHttpTransport {
|
|
5
6
|
createHttpAdapter(httpConfig: HttpConfig): AbstractHttpAdapter;
|
|
7
|
+
logFormatter(): LogFormatter;
|
|
6
8
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ExpressHttpTransport = void 0;
|
|
4
4
|
const platform_express_1 = require("@nestjs/platform-express");
|
|
5
5
|
const http_server_1 = require("@rsdk/http.server");
|
|
6
|
+
const express_log_formatter_1 = require("./express.log-formatter");
|
|
6
7
|
class ExpressHttpTransport extends http_server_1.AbstractHttpTransport {
|
|
7
8
|
createHttpAdapter(httpConfig) {
|
|
8
9
|
const { parsers } = this.options ?? {};
|
|
@@ -31,6 +32,9 @@ class ExpressHttpTransport extends http_server_1.AbstractHttpTransport {
|
|
|
31
32
|
}
|
|
32
33
|
return expressAdapter;
|
|
33
34
|
}
|
|
35
|
+
logFormatter() {
|
|
36
|
+
return new express_log_formatter_1.ExpressLogFormatter();
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
39
|
exports.ExpressHttpTransport = ExpressHttpTransport;
|
|
36
|
-
//# sourceMappingURL=express.
|
|
40
|
+
//# sourceMappingURL=express.transport.js.map
|
|
@@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ACxB,CAAC;IAED,YAAY;QACV,OAAO,IAAI,2CAAmB,EAAE,CAAC;IACnC,CAAC;CACF;AA1CD,oDA0CC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ExpressHttpTransport } from './express.
|
|
1
|
+
export { ExpressHttpTransport } from './express.transport';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExpressHttpTransport = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "ExpressHttpTransport", { enumerable: true, get: function () { return
|
|
4
|
+
var express_transport_1 = require("./express.transport");
|
|
5
|
+
Object.defineProperty(exports, "ExpressHttpTransport", { enumerable: true, get: function () { return express_transport_1.ExpressHttpTransport; } });
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yDAA2D;AAAlD,yHAAA,oBAAoB,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/http.server.express",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-next.1",
|
|
4
4
|
"description": "Adapter for @rsdk/http.server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -19,12 +19,14 @@
|
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@nestjs/common": "^10.0.0",
|
|
21
21
|
"@nestjs/core": "^10.0.0",
|
|
22
|
-
"@nestjs/platform-express": "^10.0.0",
|
|
23
22
|
"@rsdk/http.server": "*",
|
|
24
23
|
"body-parser": "^1.20.2",
|
|
25
24
|
"cookie-parser": "^1.4.6",
|
|
26
25
|
"reflect-metadata": "^0.1.12 || ^0.2.0"
|
|
27
26
|
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@nestjs/platform-express": "^10.0.0"
|
|
29
|
+
},
|
|
28
30
|
"peerDependenciesMeta": {
|
|
29
31
|
"body-parser": {
|
|
30
32
|
"optional": true
|
|
@@ -33,5 +35,5 @@
|
|
|
33
35
|
"optional": true
|
|
34
36
|
}
|
|
35
37
|
},
|
|
36
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "3114a76df17cf98d6f3cbb8a931599a883af6783"
|
|
37
39
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import type { LogFormatter } from '@rsdk/core';
|
|
3
|
+
import type { Request, Response } from 'express';
|
|
4
|
+
|
|
5
|
+
export class ExpressLogFormatter implements LogFormatter {
|
|
6
|
+
readonly protocol = 'http';
|
|
7
|
+
|
|
8
|
+
getPath(context: ExecutionContext): string {
|
|
9
|
+
const request = context.switchToHttp().getRequest<Request>();
|
|
10
|
+
|
|
11
|
+
// TODO: Может лучше голый путь - без query-параметров
|
|
12
|
+
return `${request.method} ${request.url}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
formatRequest(
|
|
16
|
+
context: ExecutionContext,
|
|
17
|
+
includeBody: boolean,
|
|
18
|
+
): Record<string, unknown> {
|
|
19
|
+
const request = context.switchToHttp().getRequest<Request>();
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
query: request.query,
|
|
23
|
+
params: request.params,
|
|
24
|
+
method: request.method,
|
|
25
|
+
url: request.url,
|
|
26
|
+
headers: request.headers,
|
|
27
|
+
...(includeBody ? { body: request.body } : {}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
formatResponse(
|
|
32
|
+
context: ExecutionContext,
|
|
33
|
+
body: unknown | undefined,
|
|
34
|
+
): Record<string, unknown> {
|
|
35
|
+
const res = context.switchToHttp().getResponse<Response>();
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
statusCode: res.statusCode,
|
|
39
|
+
headers: res.getHeaders(),
|
|
40
|
+
body,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { AbstractHttpAdapter } from '@nestjs/core';
|
|
2
2
|
import { ExpressAdapter } from '@nestjs/platform-express';
|
|
3
|
+
import type { LogFormatter } from '@rsdk/core';
|
|
3
4
|
import type { ParsersConfig } from '@rsdk/http.server';
|
|
4
5
|
import { AbstractHttpTransport } from '@rsdk/http.server';
|
|
5
6
|
import type { HttpConfig } from '@rsdk/http.server/dist/http.config';
|
|
6
7
|
|
|
8
|
+
import { ExpressLogFormatter } from './express.log-formatter';
|
|
9
|
+
|
|
7
10
|
export class ExpressHttpTransport extends AbstractHttpTransport {
|
|
8
11
|
createHttpAdapter(httpConfig: HttpConfig): AbstractHttpAdapter {
|
|
9
12
|
const { parsers } = this.options ?? {};
|
|
@@ -42,4 +45,8 @@ export class ExpressHttpTransport extends AbstractHttpTransport {
|
|
|
42
45
|
}
|
|
43
46
|
return expressAdapter;
|
|
44
47
|
}
|
|
48
|
+
|
|
49
|
+
logFormatter(): LogFormatter {
|
|
50
|
+
return new ExpressLogFormatter();
|
|
51
|
+
}
|
|
45
52
|
}
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ExpressHttpTransport } from './express.
|
|
1
|
+
export { ExpressHttpTransport } from './express.transport';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"express.http-transport.js","sourceRoot":"","sources":["../src/express.http-transport.ts"],"names":[],"mappings":";;;AACA,+DAA0D;AAE1D,mDAA0D;AAG1D,MAAa,oBAAqB,SAAQ,mCAAqB;IAC7D,iBAAiB,CAAC,UAAsB;QACtC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QACvC,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC;QACjC,MAAM,cAAc,GAAG,IAAI,iCAAc,EAAE,CAAC;QAC5C,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAkB,MAAM,CAAC,MAAM,CACnD;YACE,IAAI,EAAE;gBACJ,IAAI,EAAE,IAAI;gBACV,UAAU,EAAE,KAAK;aAClB;YACD,MAAM,EAAE,KAAK;SACd,EACD,OAAO,CACR,CAAC;QAEF,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,gGAAgG;YAChG,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;YAExC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;QACzD,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,gGAAgG;YAChG,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;YAE9C,cAAc,CAAC,GAAG,CAChB,UAAU,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,EAAE,CAAC,CACzD,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,EAAE,CAAC;YACX,gGAAgG;YAChG,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AAtCD,oDAsCC"}
|