@x1-labs/logging-nestjs 0.1.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/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/nest.d.ts +7 -0
- package/dist/nest.js +33 -0
- package/dist/nest.js.map +1 -0
- package/package.json +43 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNestLoggerModule = void 0;
|
|
4
|
+
var nest_1 = require("./nest");
|
|
5
|
+
Object.defineProperty(exports, "createNestLoggerModule", { enumerable: true, get: function () { return nest_1.createNestLoggerModule; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+BAAgD;AAAvC,8GAAA,sBAAsB,OAAA"}
|
package/dist/nest.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import type { CreateLoggerOptions } from '@x1-labs/logging';
|
|
3
|
+
export interface CreateNestLoggerModuleOptions extends CreateLoggerOptions {
|
|
4
|
+
httpLogging?: boolean;
|
|
5
|
+
forwardedIp?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function createNestLoggerModule(options?: CreateNestLoggerModuleOptions): DynamicModule;
|
package/dist/nest.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNestLoggerModule = createNestLoggerModule;
|
|
4
|
+
const nestjs_pino_1 = require("nestjs-pino");
|
|
5
|
+
const logging_1 = require("@x1-labs/logging");
|
|
6
|
+
function createNestLoggerModule(options = {}) {
|
|
7
|
+
const level = (0, logging_1.resolveLogLevel)(options.level);
|
|
8
|
+
const json = options.json ?? process.env.LOG_FORMAT === 'json';
|
|
9
|
+
const httpLogging = options.httpLogging ?? true;
|
|
10
|
+
const forwardedIp = options.forwardedIp ?? true;
|
|
11
|
+
const pinoHttp = {
|
|
12
|
+
level,
|
|
13
|
+
autoLogging: httpLogging,
|
|
14
|
+
formatters: {
|
|
15
|
+
level: (label) => ({ level: label.toUpperCase() }),
|
|
16
|
+
},
|
|
17
|
+
...(forwardedIp
|
|
18
|
+
? {
|
|
19
|
+
customProps: (req) => ({
|
|
20
|
+
ip: req.headers['x-forwarded-for']
|
|
21
|
+
?.split(',')[0]
|
|
22
|
+
?.trim() ?? req.socket?.remoteAddress,
|
|
23
|
+
}),
|
|
24
|
+
}
|
|
25
|
+
: {}),
|
|
26
|
+
transport: !json
|
|
27
|
+
? { target: 'pino-pretty', options: { singleLine: true } }
|
|
28
|
+
: undefined,
|
|
29
|
+
...options.pinoOptions,
|
|
30
|
+
};
|
|
31
|
+
return nestjs_pino_1.LoggerModule.forRoot({ pinoHttp });
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=nest.js.map
|
package/dist/nest.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest.js","sourceRoot":"","sources":["../src/nest.ts"],"names":[],"mappings":";;AAWA,wDA+BC;AAxCD,6CAA2C;AAC3C,8CAAmD;AAQnD,SAAgB,sBAAsB,CACpC,UAAyC,EAAE;IAE3C,MAAM,KAAK,GAAG,IAAA,yBAAe,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,MAAM,CAAC;IAC/D,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC;IAChD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC;IAEhD,MAAM,QAAQ,GAAG;QACf,KAAK;QACL,WAAW,EAAE,WAAW;QACxB,UAAU,EAAE;YACV,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;SAC3D;QACD,GAAG,CAAC,WAAW;YACb,CAAC,CAAC;gBACE,WAAW,EAAE,CAAC,GAAoB,EAAE,EAAE,CAAC,CAAC;oBACtC,EAAE,EACC,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAwB;wBACpD,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;wBACf,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,aAAa;iBAC1C,CAAC;aACH;YACH,CAAC,CAAC,EAAE,CAAC;QACP,SAAS,EAAE,CAAC,IAAI;YACd,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE;YAC1D,CAAC,CAAC,SAAS;QACb,GAAG,OAAO,CAAC,WAAW;KACvB,CAAC;IAEF,OAAO,0BAAY,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAkB,CAAC;AAC7D,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x1-labs/logging-nestjs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "NestJS pino logging integration",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"default": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/x1-labs/ts-logging-common.git",
|
|
16
|
+
"directory": "packages/logging-nestjs"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.build.json",
|
|
20
|
+
"prepublishOnly": "bun run build",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"lint": "eslint \"src/**/*.ts\" --fix",
|
|
23
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
24
|
+
"check": "bun run lint && bun run typecheck && bun run format --check"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@x1-labs/logging": "workspace:*"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"pino-pretty": "^13.0.0",
|
|
31
|
+
"nestjs-pino": "^4.0.0",
|
|
32
|
+
"@nestjs/common": "^11.0.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependenciesMeta": {
|
|
35
|
+
"pino-pretty": {
|
|
36
|
+
"optional": true
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist"
|
|
41
|
+
],
|
|
42
|
+
"license": "MIT"
|
|
43
|
+
}
|