micronodelib 1.0.3 → 1.0.6
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
CHANGED
@@ -26,7 +26,7 @@ import {Logger, httpContextMiddleware, requestLogMiddleware} from "micronodelib"
|
|
26
26
|
const app: Application = express();
|
27
27
|
|
28
28
|
# Enable request context
|
29
|
-
app.use(httpContextMiddleware);
|
29
|
+
app.use(httpContextMiddleware());
|
30
30
|
|
31
31
|
# Enable http request log
|
32
32
|
app.use(requestLogMiddleware({
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { NextFunction, Request, Response } from "express";
|
2
|
-
export declare const httpContextMiddleware: ((req: Request, res: Response, next: NextFunction) => void)[];
|
2
|
+
export declare const httpContextMiddleware: () => ((req: Request, res: Response, next: NextFunction) => void)[];
|
@@ -12,7 +12,10 @@ const requestIdMiddleware = (req, res, next) => {
|
|
12
12
|
(0, express_http_context_1.set)("reqId", requestId);
|
13
13
|
next();
|
14
14
|
};
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
const httpContextMiddleware = function () {
|
16
|
+
return [
|
17
|
+
express_http_context_1.middleware,
|
18
|
+
requestIdMiddleware,
|
19
|
+
];
|
20
|
+
};
|
21
|
+
exports.httpContextMiddleware = httpContextMiddleware;
|
package/dist/logging/logger.js
CHANGED
@@ -37,12 +37,13 @@ const winstonLogger = winston_1.default.createLogger({
|
|
37
37
|
format: (0, configuration_1.formatter)(info => {
|
38
38
|
info.level = info.level.toUpperCase();
|
39
39
|
info.msg = info.message;
|
40
|
-
info.ts = Date.parse(info.timestamp) / 1000;
|
40
|
+
info.ts = Math.round(Date.parse(info.timestamp) / 1000);
|
41
41
|
info.request_meta = {
|
42
42
|
request_id: (0, express_http_context_1.get)('reqId')
|
43
43
|
};
|
44
44
|
info.stacktrace = info.stack;
|
45
|
-
|
45
|
+
// @ts-ignore
|
46
|
+
delete info.message;
|
46
47
|
delete info.timestamp;
|
47
48
|
delete info.stack;
|
48
49
|
return info;
|
@@ -15,7 +15,7 @@ const requestLogMiddleware = function (opt) {
|
|
15
15
|
const req = info.meta.req;
|
16
16
|
info.level = info.level.toUpperCase();
|
17
17
|
info.msg = info.message;
|
18
|
-
info.ts = Date.parse(info.timestamp) / 1000;
|
18
|
+
info.ts = Math.round(Date.parse(info.timestamp) / 1000);
|
19
19
|
info.request_meta = {
|
20
20
|
status: info.meta.res.statusCode,
|
21
21
|
execution_time: info.meta.responseTime,
|
@@ -30,7 +30,8 @@ const requestLogMiddleware = function (opt) {
|
|
30
30
|
client_ip: req.headers['x-forwarded-for'] || (req.connection ? req.connection.remoteAddress : null),
|
31
31
|
user_agent: req.headers['user-agent']
|
32
32
|
};
|
33
|
-
|
33
|
+
// @ts-ignore
|
34
|
+
delete info.message;
|
34
35
|
delete info.timestamp;
|
35
36
|
delete info.meta;
|
36
37
|
return info;
|