xcally-nest-library 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- package/.vscode/settings.json +5 -2
- package/dist/src/config/env.validation.js +1 -0
- package/dist/src/config/env.validation.js.map +1 -1
- package/dist/src/interceptors/log-request.interceptor.js +3 -1
- package/dist/src/interceptors/log-request.interceptor.js.map +1 -1
- package/dist/src/modules/logger/winston.service.d.ts +12 -17
- package/dist/src/modules/logger/winston.service.js.map +1 -1
- package/dist/src/modules/tracer/tracer.middleware.d.ts +3 -5
- package/dist/src/modules/tracer/tracer.middleware.js.map +1 -1
- package/dist/src/types/auth.d.ts +27 -4
- package/dist/src/types/auth.js +7 -6
- package/dist/src/types/auth.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/config/env.validation.ts +2 -1
- package/src/interceptors/log-request.interceptor.ts +3 -1
- package/src/modules/logger/winston.service.ts +12 -17
- package/src/modules/tracer/tracer.middleware.ts +3 -5
- package/src/types/auth.ts +32 -4
package/.vscode/settings.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"env.validation.js","sourceRoot":"","sources":["../../../src/config/env.validation.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAiD;AACjD,
|
1
|
+
{"version":3,"file":"env.validation.js","sourceRoot":"","sources":["../../../src/config/env.validation.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAiD;AACjD,qDAA8G;AAE9G,IAAK,eAMJ;AAND,WAAK,eAAe;IAClB,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;IACnB,gCAAa,CAAA;IACb,sCAAmB,CAAA;IACnB,8BAAW,CAAA;AACb,CAAC,EANI,eAAe,KAAf,eAAe,QAMnB;AAED,MAAM,oBAAoB;CAmCzB;AAhCC;IAFC,IAAA,2BAAS,GAAE;IACX,IAAA,wBAAM,EAAC,eAAe,CAAC;;sDACE;AAG1B;IADC,IAAA,0BAAQ,GAAE;;wDACQ;AAGnB;IADC,IAAA,0BAAQ,GAAE;;wDACQ;AAInB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,6BAAW,EAAC,GAAG,CAAC;;4DACM;AAGvB;IADC,IAAA,0BAAQ,GAAE;;4DACY;AAGvB;IADC,IAAA,0BAAQ,GAAE;;4DACY;AAGvB;IADC,IAAA,2BAAS,GAAE;;+DACe;AAG3B;IADC,IAAA,0BAAQ,GAAE;;0DACU;AAGrB;IADC,IAAA,0BAAQ,GAAE;;gEACgB;AAG3B;IADC,IAAA,0BAAQ,GAAE;;6DACa;AAGxB;IADC,IAAA,0BAAQ,GAAE;;+DACe;AAG5B,SAAgB,QAAQ,CAAC,aAAsC;IAC7D,MAAM,WAAW,GAAG,IAAA,gCAAY,EAAC,oBAAoB,EAAE,aAAa,EAAE;QACpE,wBAAwB,EAAE,IAAI;KAC/B,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,IAAA,8BAAY,EAAC,WAAW,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,CAAC;IAE1E,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAZD,4BAYC"}
|
@@ -21,7 +21,8 @@ let LogRequestInterceptor = class LogRequestInterceptor {
|
|
21
21
|
const req = context.switchToHttp().getRequest();
|
22
22
|
this.logger.info('Before Middleware...', {
|
23
23
|
traceId: req?.local?.traceId,
|
24
|
-
className:
|
24
|
+
className: this.constructor.name,
|
25
|
+
methodName: 'intercept',
|
25
26
|
});
|
26
27
|
const now = Date.now();
|
27
28
|
if (req) {
|
@@ -30,6 +31,7 @@ let LogRequestInterceptor = class LogRequestInterceptor {
|
|
30
31
|
return next.handle().pipe((0, operators_1.tap)(() => this.logger.info(`After Middleware... ${method} ${url} ${Date.now() - now}ms`, {
|
31
32
|
traceId: req?.local?.traceId,
|
32
33
|
className: 'LogRequestInterceptor',
|
34
|
+
methodName: 'intercept',
|
33
35
|
})));
|
34
36
|
}
|
35
37
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"log-request.interceptor.js","sourceRoot":"","sources":["../../../src/interceptors/log-request.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4F;AAE5F,8CAAqC;AACrC,uEAAyE;AAGlE,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,YAA6B,MAA4B;QAA5B,WAAM,GAAN,MAAM,CAAsB;IAAG,CAAC;IAC7D,SAAS,CAAC,OAAyB,EAAE,IAAiB;QACpD,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAChD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE;YACvC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO;YAC5B,SAAS,EAAE,
|
1
|
+
{"version":3,"file":"log-request.interceptor.js","sourceRoot":"","sources":["../../../src/interceptors/log-request.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4F;AAE5F,8CAAqC;AACrC,uEAAyE;AAGlE,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,YAA6B,MAA4B;QAA5B,WAAM,GAAN,MAAM,CAAsB;IAAG,CAAC;IAC7D,SAAS,CAAC,OAAyB,EAAE,IAAiB;QACpD,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAChD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE;YACvC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO;YAC5B,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YAChC,UAAU,EAAE,WAAW;SACxB,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,IAAI,GAAG,EAAE,CAAC;YACR,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;YAC1B,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;YACpB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,eAAG,EAAC,GAAG,EAAE,CACP,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,EAAE;gBAC7E,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO;gBAC5B,SAAS,EAAE,uBAAuB;gBAClC,UAAU,EAAE,WAAW;aACxB,CAAC,CACH,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AAzBY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAE0B,sCAAoB;GAD9C,qBAAqB,CAyBjC"}
|
@@ -1,23 +1,18 @@
|
|
1
1
|
import { Logger } from 'winston';
|
2
2
|
import { IWinstonLogger } from './winston.interface';
|
3
|
-
|
4
|
-
traceId: string;
|
5
|
-
className?: string;
|
6
|
-
methodName?: string;
|
7
|
-
[key: string]: any;
|
8
|
-
}
|
3
|
+
import { LoggerCtx } from '../../types';
|
9
4
|
export declare class WinstonLoggerService implements IWinstonLogger {
|
10
5
|
private readonly logger;
|
11
6
|
constructor(logger: Logger);
|
12
|
-
info(message: string, meta:
|
13
|
-
warn(message: string, meta:
|
14
|
-
help(message: string, meta:
|
15
|
-
data(message: string, meta:
|
16
|
-
debug(message: string, meta:
|
17
|
-
prompt(message: string, meta:
|
18
|
-
http(message: string, meta:
|
19
|
-
verbose(message: string, meta:
|
20
|
-
input(message: string, meta:
|
21
|
-
silly(message: string, meta:
|
22
|
-
error(message: string, meta:
|
7
|
+
info(message: string, meta: LoggerCtx): void;
|
8
|
+
warn(message: string, meta: LoggerCtx): void;
|
9
|
+
help(message: string, meta: LoggerCtx): void;
|
10
|
+
data(message: string, meta: LoggerCtx): void;
|
11
|
+
debug(message: string, meta: LoggerCtx): void;
|
12
|
+
prompt(message: string, meta: LoggerCtx): void;
|
13
|
+
http(message: string, meta: LoggerCtx): void;
|
14
|
+
verbose(message: string, meta: LoggerCtx): void;
|
15
|
+
input(message: string, meta: LoggerCtx): void;
|
16
|
+
silly(message: string, meta: LoggerCtx): void;
|
17
|
+
error(message: string, meta: LoggerCtx): void;
|
23
18
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"winston.service.js","sourceRoot":"","sources":["../../../../src/modules/logger/winston.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,2DAA+C;
|
1
|
+
{"version":3,"file":"winston.service.js","sourceRoot":"","sources":["../../../../src/modules/logger/winston.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,2DAA+C;AAG/C,MAAa,oBAAoB;IAC/B,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAG/C,IAAI,CAAC,OAAe,EAAE,IAAe;QACnC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,IAAe;QACnC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,IAAe;QACnC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,IAAe;QACnC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,IAAe;QACpC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IACD,MAAM,CAAC,OAAe,EAAE,IAAe;QACrC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,IAAe;QACnC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,CAAC,OAAe,EAAE,IAAe;QACtC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,IAAe;QACpC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,IAAe;QACpC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,IAAe;QACpC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;CAGF;AAhDD,oDAgDC;AA5CC;IADC,IAAA,4BAAQ,GAAE;;;;gDAGV;AAED;IADC,IAAA,4BAAQ,GAAE;;;;gDAGV;AAED;IADC,IAAA,4BAAQ,GAAE;;;;gDAGV;AAED;IADC,IAAA,4BAAQ,GAAE;;;;gDAGV;AAED;IADC,IAAA,4BAAQ,GAAE;;;;iDAGV;AAKD;IADC,IAAA,4BAAQ,GAAE;;;;gDAGV;AAED;IADC,IAAA,4BAAQ,GAAE;;;;mDAGV;AAED;IADC,IAAA,4BAAQ,GAAE;;;;iDAGV;AAED;IADC,IAAA,4BAAQ,GAAE;;;;iDAGV;AAED;IADC,IAAA,4BAAQ,GAAE;;;;iDAGV"}
|
@@ -3,13 +3,11 @@ import { NextFunction, Request, Response } from 'express';
|
|
3
3
|
export declare const X_REQUEST_ID_HEADER = "X-Request-ID";
|
4
4
|
export declare const X_RESPONSE_ID_HEADER = "X-Response-ID";
|
5
5
|
import { RouteInfo } from '@nestjs/common/interfaces';
|
6
|
+
import { Ctx } from '../../types';
|
6
7
|
interface CtxLocal {
|
7
|
-
local:
|
8
|
+
local: Ctx;
|
8
9
|
}
|
9
|
-
|
10
|
-
traceId: string;
|
11
|
-
}
|
12
|
-
type CtxLocalRequest = Request & CtxLocal;
|
10
|
+
type CtxLocalRequest = Request & Ctx;
|
13
11
|
export interface TracingModuleOptions {
|
14
12
|
routes: (string | RouteInfo)[];
|
15
13
|
excludedRoutes?: (string | RouteInfo)[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tracer.middleware.js","sourceRoot":"","sources":["../../../../src/modules/tracer/tracer.middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoE;AACpE,mCAAoC;AAEvB,QAAA,mBAAmB,GAAG,cAAc,CAAC;AACrC,QAAA,oBAAoB,GAAG,eAAe,CAAC;AACpD,2CAA2D;
|
1
|
+
{"version":3,"file":"tracer.middleware.js","sourceRoot":"","sources":["../../../../src/modules/tracer/tracer.middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoE;AACpE,mCAAoC;AAEvB,QAAA,mBAAmB,GAAG,cAAc,CAAC;AACrC,QAAA,oBAAoB,GAAG,eAAe,CAAC;AACpD,2CAA2D;AAe9C,KACX,IAAI,kCAAyB,EAAwB,CAAC,KAAK,EAAE,EADhD,+BAAuB,+BAAE,4BAAoB,4BAAE,oBAAY,oBAAE,0BAAkB,yBAC9B;AAGzD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,YAEqB,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;IAC9C,CAAC;IAEJ,KAAK,CAAC,GAAG,CAAC,GAA+B,EAAE,GAAa,EAAE,IAAkB;QAC1E,MAAM,EAAE,SAAS,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACzD,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,2BAAmB,CAAC,IAAI,IAAA,mBAAU,GAAE,CAAC;QAC7D,GAAG,CAAC,KAAK,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC9B,GAAG,CAAC,SAAS,CAAC,4BAAoB,EAAE,IAAI,CAAC,CAAC;QAC1C,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;CACF,CAAA;AAbY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,4BAAoB,CAAC,CAAA;;GAFpB,gBAAgB,CAa5B"}
|
package/dist/src/types/auth.d.ts
CHANGED
@@ -1,8 +1,31 @@
|
|
1
|
+
export type UserPermission = {
|
2
|
+
sectionId: number;
|
3
|
+
name: string;
|
4
|
+
category: string;
|
5
|
+
crudPermissions: Array<'r' | 'e' | 'd'>;
|
6
|
+
};
|
1
7
|
export type User = {
|
2
|
-
|
8
|
+
id: number;
|
9
|
+
role: Role;
|
3
10
|
name: string;
|
11
|
+
userProfileId: number;
|
12
|
+
permissions: UserPermission[];
|
13
|
+
};
|
14
|
+
export type Ctx = {
|
15
|
+
traceId: string;
|
16
|
+
user?: User;
|
17
|
+
auth?: Auth;
|
4
18
|
};
|
5
|
-
export
|
6
|
-
|
7
|
-
|
19
|
+
export type LoggerCtx = Ctx & {
|
20
|
+
className: string;
|
21
|
+
methodName: string;
|
22
|
+
[key: string]: any;
|
23
|
+
};
|
24
|
+
export declare enum Role {
|
25
|
+
User = "user",
|
26
|
+
Admin = "admin",
|
27
|
+
Agent = "agent"
|
8
28
|
}
|
29
|
+
export type Auth = {
|
30
|
+
token: string;
|
31
|
+
};
|
package/dist/src/types/auth.js
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
4
|
-
var
|
5
|
-
(function (
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
exports.Role = void 0;
|
4
|
+
var Role;
|
5
|
+
(function (Role) {
|
6
|
+
Role["User"] = "user";
|
7
|
+
Role["Admin"] = "admin";
|
8
|
+
Role["Agent"] = "agent";
|
9
|
+
})(Role || (exports.Role = Role = {}));
|
9
10
|
//# sourceMappingURL=auth.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/types/auth.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/types/auth.ts"],"names":[],"mappings":";;;AA4BA,IAAY,IAIX;AAJD,WAAY,IAAI;IACd,qBAAa,CAAA;IACb,uBAAe,CAAA;IACf,uBAAe,CAAA;AACjB,CAAC,EAJW,IAAI,oBAAJ,IAAI,QAIf"}
|