xcally-nest-library 0.0.19 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -4,7 +4,6 @@ export * from './src/interceptors/serialize.interceptor';
4
4
  export * from './src/modules/logger/winston.service';
5
5
  export * from './src/modules/logger/winston.module';
6
6
  export * from './src/modules/tracer/tracer.module';
7
- export * from './src/db/typeorm/generic.repository';
8
7
  export * from './src/decorators/utils.decorators';
9
8
  export * from './src/config/env.validation';
10
9
  export * from './src/modules/logger/pino/logger.service';
package/dist/index.js CHANGED
@@ -20,7 +20,6 @@ __exportStar(require("./src/interceptors/serialize.interceptor"), exports);
20
20
  __exportStar(require("./src/modules/logger/winston.service"), exports);
21
21
  __exportStar(require("./src/modules/logger/winston.module"), exports);
22
22
  __exportStar(require("./src/modules/tracer/tracer.module"), exports);
23
- __exportStar(require("./src/db/typeorm/generic.repository"), exports);
24
23
  __exportStar(require("./src/decorators/utils.decorators"), exports);
25
24
  __exportStar(require("./src/config/env.validation"), exports);
26
25
  __exportStar(require("./src/modules/logger/pino/logger.service"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6EAA2D;AAC3D,2EAAyD;AACzD,uEAAqD;AACrD,sEAAoD;AACpD,qEAAmD;AACnD,sEAAoD;AACpD,oEAAkD;AAClD,8DAA4C;AAC5C,2EAAyD;AACzD,0EAAwD;AACxD,2EAAyD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6EAA2D;AAC3D,2EAAyD;AACzD,uEAAqD;AACrD,sEAAoD;AACpD,qEAAmD;AACnD,oEAAkD;AAClD,8DAA4C;AAC5C,2EAAyD;AACzD,0EAAwD;AACxD,2EAAyD"}
@@ -1,9 +1,7 @@
1
1
  import { Repository, EntityTarget, EntityManager, FindOptionsWhere, ObjectLiteral, DeepPartial } from 'typeorm';
2
2
  import { PaginateConfig, PaginateQuery, Paginated } from 'nestjs-paginate';
3
- interface IId {
4
- id: number;
5
- }
6
- export declare class GenericRepository<E extends ObjectLiteral> {
3
+ import { IGenericRepository, IId } from './generic.repository.interface';
4
+ export declare class GenericRepository<E extends ObjectLiteral> implements IGenericRepository<E> {
7
5
  private readonly entityManager;
8
6
  protected repository: Repository<E>;
9
7
  protected paginateConfig: PaginateConfig<E>;
@@ -18,4 +16,3 @@ export declare class GenericRepository<E extends ObjectLiteral> {
18
16
  remove(id: number): Promise<void>;
19
17
  remove2(id: number): Promise<void>;
20
18
  }
21
- export {};
@@ -0,0 +1,15 @@
1
+ import { PaginateQuery, Paginated } from 'nestjs-paginate';
2
+ import { DeepPartial, FindOptionsWhere } from 'typeorm';
3
+ export interface IId {
4
+ id: number;
5
+ }
6
+ export interface IGenericRepository<E> {
7
+ getMany(query: PaginateQuery): Promise<Paginated<E>>;
8
+ save<T extends DeepPartial<E>>(entity: T): Promise<E>;
9
+ update<T extends DeepPartial<E> & IId>(dto: T): Promise<E>;
10
+ count(options: FindOptionsWhere<E>): Promise<number>;
11
+ findAll(): Promise<E[]>;
12
+ countAll(): Promise<number>;
13
+ findById(id: number): Promise<E>;
14
+ remove(id: number): Promise<void>;
15
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generic.repository.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic.repository.interface.js","sourceRoot":"","sources":["../../../../src/db/typeorm/generic.repository.interface.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"generic.repository.js","sourceRoot":"","sources":["../../../../src/db/typeorm/generic.repository.ts"],"names":[],"mappings":";;;AAAA,qCAAuH;AACvH,qDAAqF;AASrF,MAAa,iBAAiB;IAI5B,YACmB,aAA4B,EAC7C,MAAuB,EACvB,cAAi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,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAA,eAAK,EAAC,GAAG,CAAC,EAAE,CAAC,EAAoC,CAAC,CAAC;IAC5F,CAAC;IAQD,KAAK,CAAC,OAA4B;QAChC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAOD,OAAO;QACL,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC;IAOD,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAQD,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;YACrC,EAAE,EAAE,IAAA,eAAK,EAAC,EAAE,CAAC;SACoB,CAAC,CAAC;IACvC,CAAC;IAQD,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC;CACF;AAnGD,8CAmGC"}
@@ -1,4 +1,2 @@
1
- import { DynamicModule } from '@nestjs/common';
2
1
  export declare class LoggerModule {
3
- static forRoot(): DynamicModule;
4
2
  }
@@ -5,62 +5,64 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  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;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
- var LoggerModule_1;
9
8
  Object.defineProperty(exports, "__esModule", { value: true });
10
9
  exports.LoggerModule = void 0;
11
10
  const common_1 = require("@nestjs/common");
12
11
  const config_1 = require("@nestjs/config");
13
12
  const nestjs_pino_1 = require("nestjs-pino");
14
13
  const logger_service_1 = require("./logger.service");
15
- let LoggerModule = LoggerModule_1 = class LoggerModule {
16
- static forRoot() {
17
- return {
18
- module: LoggerModule_1,
19
- providers: [logger_service_1.LoggerService],
20
- exports: [logger_service_1.LoggerService],
21
- imports: [
22
- nestjs_pino_1.LoggerModule.forRootAsync({
23
- imports: [config_1.ConfigModule],
24
- inject: [config_1.ConfigService],
25
- useFactory: async (config) => {
26
- const projectName = process.env.npm_package_name || 'default_project';
27
- return {
28
- pinoHttp: {
29
- level: config.get('LOG_LEVEL') || 'info',
30
- redact: {
31
- paths: ['req.headers.cookie', 'req.headers.authorization'],
32
- },
33
- transport: {
34
- targets: [
35
- {
36
- level: 'debug',
37
- target: 'pino-pretty',
38
- options: {
39
- colorize: true,
40
- },
41
- },
42
- {
43
- level: 'info',
44
- target: 'pino/file',
45
- options: {
46
- destination: `./logs/${projectName}-info.log`,
47
- mkdir: true,
48
- append: process.env.NODE_ENV !== 'production' ? false : true,
49
- },
50
- },
51
- ],
52
- },
53
- },
54
- };
55
- },
56
- }),
57
- ],
58
- };
59
- }
14
+ let LoggerModule = class LoggerModule {
60
15
  };
61
16
  exports.LoggerModule = LoggerModule;
62
- exports.LoggerModule = LoggerModule = LoggerModule_1 = __decorate([
17
+ exports.LoggerModule = LoggerModule = __decorate([
63
18
  (0, common_1.Global)(),
64
- (0, common_1.Module)({})
19
+ (0, common_1.Module)({
20
+ providers: [logger_service_1.LoggerService],
21
+ exports: [logger_service_1.LoggerService],
22
+ imports: [
23
+ nestjs_pino_1.LoggerModule.forRootAsync({
24
+ imports: [config_1.ConfigModule],
25
+ inject: [config_1.ConfigService],
26
+ useFactory: async (config) => {
27
+ const projectName = process.env.npm_package_name || 'default_project';
28
+ return {
29
+ pinoHttp: {
30
+ customLogLevel: (req, res) => {
31
+ if (res.statusCode >= 500)
32
+ return 'error';
33
+ if (res.statusCode >= 400)
34
+ return 'warn';
35
+ return 'info';
36
+ },
37
+ level: config.get('LOG_LEVEL') || 'info',
38
+ redact: {
39
+ paths: ['req.headers.cookie', 'req.headers.authorization'],
40
+ },
41
+ transport: {
42
+ targets: [
43
+ {
44
+ level: 'debug',
45
+ target: 'pino-pretty',
46
+ options: {
47
+ colorize: true,
48
+ },
49
+ },
50
+ {
51
+ level: 'info',
52
+ target: 'pino/file',
53
+ options: {
54
+ destination: `./logs/${projectName}-info.log`,
55
+ mkdir: true,
56
+ append: process.env.NODE_ENV !== 'production' ? false : true,
57
+ },
58
+ },
59
+ ],
60
+ },
61
+ },
62
+ };
63
+ },
64
+ }),
65
+ ],
66
+ })
65
67
  ], LoggerModule);
66
68
  //# sourceMappingURL=logger.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.module.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/logger.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+D;AAC/D,2CAA6D;AAC7D,6CAA+D;AAC/D,qDAAiD;AAI1C,IAAM,YAAY,oBAAlB,MAAM,YAAY;IACvB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,cAAY;YACpB,SAAS,EAAE,CAAC,8BAAa,CAAC;YAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;YACxB,OAAO,EAAE;gBACP,0BAAgB,CAAC,YAAY,CAAC;oBAC5B,OAAO,EAAE,CAAC,qBAAY,CAAC;oBACvB,MAAM,EAAE,CAAC,sBAAa,CAAC;oBACvB,UAAU,EAAE,KAAK,EAAE,MAAqB,EAAE,EAAE;wBAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,iBAAiB,CAAC;wBACtE,OAAO;4BACL,QAAQ,EAAE;gCACR,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,MAAM;gCAWxC,MAAM,EAAE;oCACN,KAAK,EAAE,CAAC,oBAAoB,EAAE,2BAA2B,CAAC;iCAC3D;gCACD,SAAS,EAAE;oCACT,OAAO,EAAE;wCACP;4CACE,KAAK,EAAE,OAAO;4CACd,MAAM,EAAE,aAAa;4CACrB,OAAO,EAAE;gDACP,QAAQ,EAAE,IAAI;6CACf;yCACF;wCAQD;4CACE,KAAK,EAAE,MAAM;4CACb,MAAM,EAAE,WAAW;4CACnB,OAAO,EAAE;gDACP,WAAW,EAAE,UAAU,WAAW,WAAW;gDAC7C,KAAK,EAAE,IAAI;gDACX,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;6CAC7D;yCACF;qCACF;iCACF;6BAKF;yBACF,CAAC;oBACJ,CAAC;iBACF,CAAC;aACH;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAlEY,oCAAY;uBAAZ,YAAY;IAFxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,YAAY,CAkExB"}
1
+ {"version":3,"file":"logger.module.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/logger.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,2CAA6D;AAC7D,6CAA+D;AAC/D,qDAAiD;AAsE1C,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IApExB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;QACxB,OAAO,EAAE;YACP,0BAAgB,CAAC,YAAY,CAAC;gBAC5B,OAAO,EAAE,CAAC,qBAAY,CAAC;gBACvB,MAAM,EAAE,CAAC,sBAAa,CAAC;gBACvB,UAAU,EAAE,KAAK,EAAE,MAAqB,EAAE,EAAE;oBAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IA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