safesafar-common 1.0.11
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/constants/index.ts +1 -0
- package/constants/services.ts +1 -0
- package/decorators/current-user.decorator.ts +11 -0
- package/decorators/index.ts +1 -0
- package/dist/index.d.mts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +138 -0
- package/dist/index.mjs +109 -0
- package/guards/index.ts +1 -0
- package/guards/jwt-auth.guard.ts +40 -0
- package/index.ts +5 -0
- package/package.json +37 -0
- package/services/index.ts +1 -0
- package/services/logger/common.logger.ts +6 -0
- package/services/logger/index.ts +2 -0
- package/services/logger/logger.module.ts +19 -0
- package/tsconfig.json +14 -0
- package/types/index.ts +1 -0
- package/types/logger.ts +3 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './services';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const NATS_SERVICE: string = 'NATS_SERVICE';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createParamDecorator, ExecutionContext } from "@nestjs/common";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const getCurrentUserByContext = (ctx: ExecutionContext): any => {
|
|
5
|
+
return ctx.switchToHttp().getRequest().user;
|
|
6
|
+
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const CurrentUser = createParamDecorator(
|
|
10
|
+
(data: unknown, ctx: ExecutionContext) => getCurrentUserByContext(ctx)
|
|
11
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './current-user.decorator'
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext, Logger } from '@nestjs/common';
|
|
2
|
+
import { ClientProxy } from '@nestjs/microservices';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
declare const NATS_SERVICE: string;
|
|
6
|
+
|
|
7
|
+
declare class JwtAuthGuard implements CanActivate {
|
|
8
|
+
private readonly authClient;
|
|
9
|
+
constructor(authClient: ClientProxy);
|
|
10
|
+
canActivate(context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare class LoggerModule {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type TCustomLogger = Logger;
|
|
17
|
+
|
|
18
|
+
declare const createLogger: (name: string) => TCustomLogger;
|
|
19
|
+
|
|
20
|
+
declare const CurrentUser: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
21
|
+
|
|
22
|
+
export { CurrentUser, JwtAuthGuard, LoggerModule, NATS_SERVICE, type TCustomLogger, createLogger };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext, Logger } from '@nestjs/common';
|
|
2
|
+
import { ClientProxy } from '@nestjs/microservices';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
declare const NATS_SERVICE: string;
|
|
6
|
+
|
|
7
|
+
declare class JwtAuthGuard implements CanActivate {
|
|
8
|
+
private readonly authClient;
|
|
9
|
+
constructor(authClient: ClientProxy);
|
|
10
|
+
canActivate(context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare class LoggerModule {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type TCustomLogger = Logger;
|
|
17
|
+
|
|
18
|
+
declare const createLogger: (name: string) => TCustomLogger;
|
|
19
|
+
|
|
20
|
+
declare const CurrentUser: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
21
|
+
|
|
22
|
+
export { CurrentUser, JwtAuthGuard, LoggerModule, NATS_SERVICE, type TCustomLogger, createLogger };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
|
|
23
|
+
// index.ts
|
|
24
|
+
var libs_exports = {};
|
|
25
|
+
__export(libs_exports, {
|
|
26
|
+
CurrentUser: () => CurrentUser,
|
|
27
|
+
JwtAuthGuard: () => JwtAuthGuard,
|
|
28
|
+
LoggerModule: () => LoggerModule,
|
|
29
|
+
NATS_SERVICE: () => NATS_SERVICE,
|
|
30
|
+
createLogger: () => createLogger
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(libs_exports);
|
|
33
|
+
|
|
34
|
+
// constants/services.ts
|
|
35
|
+
var NATS_SERVICE = "NATS_SERVICE";
|
|
36
|
+
|
|
37
|
+
// guards/jwt-auth.guard.ts
|
|
38
|
+
var import_common = require("@nestjs/common");
|
|
39
|
+
var import_microservices = require("@nestjs/microservices");
|
|
40
|
+
var import_rxjs = require("rxjs");
|
|
41
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
42
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
43
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
44
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
45
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
46
|
+
}
|
|
47
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
48
|
+
function _ts_metadata(k, v) {
|
|
49
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
50
|
+
}
|
|
51
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
52
|
+
function _ts_param(paramIndex, decorator) {
|
|
53
|
+
return function(target, key) {
|
|
54
|
+
decorator(target, key, paramIndex);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
__name(_ts_param, "_ts_param");
|
|
58
|
+
var _JwtAuthGuard = class _JwtAuthGuard {
|
|
59
|
+
constructor(authClient) {
|
|
60
|
+
__publicField(this, "authClient");
|
|
61
|
+
this.authClient = authClient;
|
|
62
|
+
}
|
|
63
|
+
canActivate(context) {
|
|
64
|
+
const request = context.switchToHttp().getRequest();
|
|
65
|
+
const token = request.cookies?.["Authentication"];
|
|
66
|
+
if (!token) {
|
|
67
|
+
throw false;
|
|
68
|
+
}
|
|
69
|
+
return this.authClient.send("authenticate", {
|
|
70
|
+
Authentication: token
|
|
71
|
+
}).pipe((0, import_rxjs.tap)((res) => {
|
|
72
|
+
context.switchToHttp().getRequest().user = res;
|
|
73
|
+
}), (0, import_rxjs.map)(() => true), (0, import_rxjs.catchError)(() => (0, import_rxjs.of)(false)));
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
__name(_JwtAuthGuard, "JwtAuthGuard");
|
|
77
|
+
var JwtAuthGuard = _JwtAuthGuard;
|
|
78
|
+
JwtAuthGuard = _ts_decorate([
|
|
79
|
+
(0, import_common.Injectable)(),
|
|
80
|
+
_ts_param(0, (0, import_common.Inject)(NATS_SERVICE)),
|
|
81
|
+
_ts_metadata("design:type", Function),
|
|
82
|
+
_ts_metadata("design:paramtypes", [
|
|
83
|
+
typeof import_microservices.ClientProxy === "undefined" ? Object : import_microservices.ClientProxy
|
|
84
|
+
])
|
|
85
|
+
], JwtAuthGuard);
|
|
86
|
+
|
|
87
|
+
// services/logger/logger.module.ts
|
|
88
|
+
var import_common2 = require("@nestjs/common");
|
|
89
|
+
var import_nestjs_pino = require("nestjs-pino");
|
|
90
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
91
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
92
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
93
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
94
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
95
|
+
}
|
|
96
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
97
|
+
var _LoggerModule = class _LoggerModule {
|
|
98
|
+
};
|
|
99
|
+
__name(_LoggerModule, "LoggerModule");
|
|
100
|
+
var LoggerModule = _LoggerModule;
|
|
101
|
+
LoggerModule = _ts_decorate2([
|
|
102
|
+
(0, import_common2.Module)({
|
|
103
|
+
imports: [
|
|
104
|
+
import_nestjs_pino.LoggerModule.forRoot({
|
|
105
|
+
pinoHttp: {
|
|
106
|
+
transport: {
|
|
107
|
+
target: "pino-pretty",
|
|
108
|
+
options: {
|
|
109
|
+
colorize: true,
|
|
110
|
+
singleLine: true
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
})
|
|
117
|
+
], LoggerModule);
|
|
118
|
+
|
|
119
|
+
// services/logger/common.logger.ts
|
|
120
|
+
var import_common3 = require("@nestjs/common");
|
|
121
|
+
var createLogger = /* @__PURE__ */ __name((name) => {
|
|
122
|
+
return new import_common3.Logger(name);
|
|
123
|
+
}, "createLogger");
|
|
124
|
+
|
|
125
|
+
// decorators/current-user.decorator.ts
|
|
126
|
+
var import_common4 = require("@nestjs/common");
|
|
127
|
+
var getCurrentUserByContext = /* @__PURE__ */ __name((ctx) => {
|
|
128
|
+
return ctx.switchToHttp().getRequest().user;
|
|
129
|
+
}, "getCurrentUserByContext");
|
|
130
|
+
var CurrentUser = (0, import_common4.createParamDecorator)((data, ctx) => getCurrentUserByContext(ctx));
|
|
131
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
132
|
+
0 && (module.exports = {
|
|
133
|
+
CurrentUser,
|
|
134
|
+
JwtAuthGuard,
|
|
135
|
+
LoggerModule,
|
|
136
|
+
NATS_SERVICE,
|
|
137
|
+
createLogger
|
|
138
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
|
|
6
|
+
// constants/services.ts
|
|
7
|
+
var NATS_SERVICE = "NATS_SERVICE";
|
|
8
|
+
|
|
9
|
+
// guards/jwt-auth.guard.ts
|
|
10
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
11
|
+
import { ClientProxy } from "@nestjs/microservices";
|
|
12
|
+
import { catchError, map, of, tap } from "rxjs";
|
|
13
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
14
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
+
}
|
|
19
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
20
|
+
function _ts_metadata(k, v) {
|
|
21
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
|
+
}
|
|
23
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
24
|
+
function _ts_param(paramIndex, decorator) {
|
|
25
|
+
return function(target, key) {
|
|
26
|
+
decorator(target, key, paramIndex);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
__name(_ts_param, "_ts_param");
|
|
30
|
+
var _JwtAuthGuard = class _JwtAuthGuard {
|
|
31
|
+
constructor(authClient) {
|
|
32
|
+
__publicField(this, "authClient");
|
|
33
|
+
this.authClient = authClient;
|
|
34
|
+
}
|
|
35
|
+
canActivate(context) {
|
|
36
|
+
const request = context.switchToHttp().getRequest();
|
|
37
|
+
const token = request.cookies?.["Authentication"];
|
|
38
|
+
if (!token) {
|
|
39
|
+
throw false;
|
|
40
|
+
}
|
|
41
|
+
return this.authClient.send("authenticate", {
|
|
42
|
+
Authentication: token
|
|
43
|
+
}).pipe(tap((res) => {
|
|
44
|
+
context.switchToHttp().getRequest().user = res;
|
|
45
|
+
}), map(() => true), catchError(() => of(false)));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
__name(_JwtAuthGuard, "JwtAuthGuard");
|
|
49
|
+
var JwtAuthGuard = _JwtAuthGuard;
|
|
50
|
+
JwtAuthGuard = _ts_decorate([
|
|
51
|
+
Injectable(),
|
|
52
|
+
_ts_param(0, Inject(NATS_SERVICE)),
|
|
53
|
+
_ts_metadata("design:type", Function),
|
|
54
|
+
_ts_metadata("design:paramtypes", [
|
|
55
|
+
typeof ClientProxy === "undefined" ? Object : ClientProxy
|
|
56
|
+
])
|
|
57
|
+
], JwtAuthGuard);
|
|
58
|
+
|
|
59
|
+
// services/logger/logger.module.ts
|
|
60
|
+
import { Module } from "@nestjs/common";
|
|
61
|
+
import { LoggerModule as PinoLoggerModule } from "nestjs-pino";
|
|
62
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
63
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
64
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
65
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
66
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
67
|
+
}
|
|
68
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
69
|
+
var _LoggerModule = class _LoggerModule {
|
|
70
|
+
};
|
|
71
|
+
__name(_LoggerModule, "LoggerModule");
|
|
72
|
+
var LoggerModule = _LoggerModule;
|
|
73
|
+
LoggerModule = _ts_decorate2([
|
|
74
|
+
Module({
|
|
75
|
+
imports: [
|
|
76
|
+
PinoLoggerModule.forRoot({
|
|
77
|
+
pinoHttp: {
|
|
78
|
+
transport: {
|
|
79
|
+
target: "pino-pretty",
|
|
80
|
+
options: {
|
|
81
|
+
colorize: true,
|
|
82
|
+
singleLine: true
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
})
|
|
89
|
+
], LoggerModule);
|
|
90
|
+
|
|
91
|
+
// services/logger/common.logger.ts
|
|
92
|
+
import { Logger } from "@nestjs/common";
|
|
93
|
+
var createLogger = /* @__PURE__ */ __name((name) => {
|
|
94
|
+
return new Logger(name);
|
|
95
|
+
}, "createLogger");
|
|
96
|
+
|
|
97
|
+
// decorators/current-user.decorator.ts
|
|
98
|
+
import { createParamDecorator } from "@nestjs/common";
|
|
99
|
+
var getCurrentUserByContext = /* @__PURE__ */ __name((ctx) => {
|
|
100
|
+
return ctx.switchToHttp().getRequest().user;
|
|
101
|
+
}, "getCurrentUserByContext");
|
|
102
|
+
var CurrentUser = createParamDecorator((data, ctx) => getCurrentUserByContext(ctx));
|
|
103
|
+
export {
|
|
104
|
+
CurrentUser,
|
|
105
|
+
JwtAuthGuard,
|
|
106
|
+
LoggerModule,
|
|
107
|
+
NATS_SERVICE,
|
|
108
|
+
createLogger
|
|
109
|
+
};
|
package/guards/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './jwt-auth.guard';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CanActivate,
|
|
3
|
+
ExecutionContext,
|
|
4
|
+
Inject,
|
|
5
|
+
Injectable,
|
|
6
|
+
} from "@nestjs/common";
|
|
7
|
+
import { ClientProxy } from "@nestjs/microservices";
|
|
8
|
+
import { catchError, map, Observable, of, tap } from "rxjs";
|
|
9
|
+
import { NATS_SERVICE } from "../constants";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@Injectable()
|
|
13
|
+
export class JwtAuthGuard implements CanActivate {
|
|
14
|
+
constructor(
|
|
15
|
+
@Inject(NATS_SERVICE) private readonly authClient: ClientProxy
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
canActivate(
|
|
19
|
+
context: ExecutionContext
|
|
20
|
+
): boolean | Promise<boolean> | Observable<boolean> {
|
|
21
|
+
const request = context.switchToHttp().getRequest();
|
|
22
|
+
const token = request.cookies?.["Authentication"];
|
|
23
|
+
|
|
24
|
+
if (!token) {
|
|
25
|
+
throw false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return this.authClient
|
|
29
|
+
.send<{ _id: string; email: string; password: string }>("authenticate", {
|
|
30
|
+
Authentication: token,
|
|
31
|
+
})
|
|
32
|
+
.pipe(
|
|
33
|
+
tap((res) => {
|
|
34
|
+
context.switchToHttp().getRequest().user = res;
|
|
35
|
+
}),
|
|
36
|
+
map(() => true),
|
|
37
|
+
catchError(() => of(false))
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
package/index.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "safesafar-common",
|
|
3
|
+
"version": "1.0.11",
|
|
4
|
+
"description": "Common library for SafeSafar",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"author": "SafeSafar",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"module": "dist/index.mjs",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsup index.ts --format cjs,esm --dts",
|
|
16
|
+
"lint": "tsc",
|
|
17
|
+
"publish": "npm run build && npm publish"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@nestjs/common": "^10.0.0",
|
|
21
|
+
"@nestjs/core": "^10.0.0",
|
|
22
|
+
"@nestjs/mapped-types": "*",
|
|
23
|
+
"@nestjs/microservices": "^10.4.4",
|
|
24
|
+
"@swc/core": "^1.7.26",
|
|
25
|
+
"class-transformer": "^0.5.1",
|
|
26
|
+
"class-validator": "^0.14.1",
|
|
27
|
+
"nestjs-pino": "^4.1.0",
|
|
28
|
+
"pino-http": "^10.3.0",
|
|
29
|
+
"reflect-metadata": "^0.2.0",
|
|
30
|
+
"rxjs": "^7.8.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^22.7.4",
|
|
34
|
+
"tsup": "^8.1.0",
|
|
35
|
+
"typescript": "^5.1.3"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './logger';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { LoggerModule as PinoLoggerModule } from 'nestjs-pino';
|
|
3
|
+
|
|
4
|
+
@Module({
|
|
5
|
+
imports: [
|
|
6
|
+
PinoLoggerModule.forRoot({
|
|
7
|
+
pinoHttp: {
|
|
8
|
+
transport: {
|
|
9
|
+
target: 'pino-pretty',
|
|
10
|
+
options: {
|
|
11
|
+
colorize: true,
|
|
12
|
+
singleLine: true,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
17
|
+
]
|
|
18
|
+
})
|
|
19
|
+
export class LoggerModule {}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2021",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"noEmit": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"forceConsistentCasingInFileNames": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"noUncheckedIndexedAccess": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"emitDecoratorMetadata": true
|
|
13
|
+
}
|
|
14
|
+
}
|
package/types/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './logger'
|
package/types/logger.ts
ADDED