@vuvannghiawork/common 0.0.28 → 0.0.30

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.
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.BaseAppController = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
+ const swagger_1 = require("@nestjs/swagger");
14
15
  let BaseAppController = class BaseAppController {
15
16
  getHello() {
16
17
  return 'Hello World!';
@@ -33,6 +34,7 @@ __decorate([
33
34
  __metadata("design:returntype", String)
34
35
  ], BaseAppController.prototype, "getEnv", null);
35
36
  exports.BaseAppController = BaseAppController = __decorate([
37
+ (0, swagger_1.ApiTags)('App'),
36
38
  (0, common_1.Controller)()
37
39
  ], BaseAppController);
38
40
  //# sourceMappingURL=base-app.controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-app.controller.js","sourceRoot":"","sources":["../../src/controllers/base-app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AAG1C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAE5B,QAAQ;QACN,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,MAAM;QACJ,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,qBAAqB,CAAC;IAC1D,CAAC;CACF,CAAA;AATY,8CAAiB;AAE5B;IADC,IAAA,YAAG,GAAE;;;;iDAGL;AAED;IADC,IAAA,YAAG,EAAC,KAAK,CAAC;;;;+CAGV;4BARU,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAS7B"}
1
+ {"version":3,"file":"base-app.controller.js","sourceRoot":"","sources":["../../src/controllers/base-app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AACjD,6CAA0C;AAInC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAE5B,QAAQ;QACN,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,MAAM;QACJ,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,qBAAqB,CAAC;IAC1D,CAAC;CACF,CAAA;AATY,8CAAiB;AAE5B;IADC,IAAA,YAAG,GAAE;;;;iDAGL;AAED;IADC,IAAA,YAAG,EAAC,KAAK,CAAC;;;;+CAGV;4BARU,iBAAiB;IAF7B,IAAA,iBAAO,EAAC,KAAK,CAAC;IACd,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAS7B"}
@@ -0,0 +1 @@
1
+ export declare function Auth(): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Auth = Auth;
4
+ const common_1 = require("@nestjs/common");
5
+ const jwt_auth_guard_1 = require("../guards/jwt-auth.guard");
6
+ function Auth() {
7
+ return (0, common_1.applyDecorators)((0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard));
8
+ }
9
+ //# sourceMappingURL=current-user.decorator%20copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current-user.decorator copy.js","sourceRoot":"","sources":["../../src/decorators/current-user.decorator copy.ts"],"names":[],"mappings":";;AAIA,oBAIC;AARD,2CAA4D;AAC5D,6DAAyD;AAGzD,SAAgB,IAAI;IAClB,OAAO,IAAA,wBAAe,EACpB,IAAA,kBAAS,EAAC,6BAAY,CAAC,CACxB,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"current-user.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-user.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAE3D,QAAA,WAAW,GAAG,IAAA,6BAAoB,EAC7C,CAAC,IAAa,EAAE,GAAqB,EAAE,EAAE;IACvC,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC,CACF,CAAC"}
1
+ {"version":3,"file":"current-user.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-user.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAI3D,QAAA,WAAW,GAAG,IAAA,6BAAoB,EAC7C,CAAC,IAAa,EAAE,GAAqB,EAAe,EAAE;IACpD,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC,CACF,CAAC"}
@@ -3,15 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.logAppBootstrap = logAppBootstrap;
4
4
  const swagger_constant_1 = require("../constants/swagger.constant");
5
5
  function logAppBootstrap(port) {
6
- const env = process.env.ENVIRONMENT || 'development';
7
- const name = process.env.NAME || 'Microservice';
8
- const dbUrl = process.env.DATABASE_URL || 'N/A';
9
6
  console.log('='.repeat(60));
10
- console.log(`ENVIRONMENT: ${env}`);
11
- console.log(`NAME: ${name}`);
7
+ console.log(`ENVIRONMENT: ${process.env.ENVIRONMENT}`);
8
+ console.log(`NAME: ${process.env.NAME}`);
12
9
  console.log(`PORT: ${port}`);
13
10
  console.log(`Application is running on: http://toeicHUST.local:${port}/${swagger_constant_1.SWAGGER_DOCS_PATH}`);
14
- console.log(`DATABASE_URL: ${dbUrl}`);
11
+ console.log(`DATABASE_URL: ${process.env.DATABASE_URL}`);
15
12
  console.log('='.repeat(60));
16
13
  }
17
14
  //# sourceMappingURL=bootstrap.helper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.helper.js","sourceRoot":"","sources":["../../src/helpers/bootstrap.helper.ts"],"names":[],"mappings":";;AAEA,0CAeC;AAjBD,oEAAmE;AAEnE,SAAgB,eAAe,CAAC,IAAqB;IACnD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,aAAa,CAAC;IACr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,YAAY,EAAE,CAAC,CAAC;IAEzD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  export * from './constants/auth-strategy.constant';
2
2
  export * from './constants/swagger.constant';
3
3
  export * from './controllers/base-app.controller';
4
+ export * from './decorators/current-user.decorator copy';
4
5
  export * from './decorators/current-user.decorator';
5
6
  export * from './filters/error-handler.filter';
6
7
  export * from './guards/jwt-auth.guard';
7
8
  export * from './helpers/bootstrap.helper';
8
9
  export * from './helpers/swagger.helper';
9
10
  export * from './interfaces/jwt-payload.interface';
11
+ export * from './interfaces/user-payload.interface';
10
12
  export * from './middlewares/logger.middleware';
13
+ export * from './modules/base-auth.module';
11
14
  export * from './strategies/base-jwt.strategy';
12
15
  export * from './strategies/common-jwt.strategy';
package/dist/index.js CHANGED
@@ -17,13 +17,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./constants/auth-strategy.constant"), exports);
18
18
  __exportStar(require("./constants/swagger.constant"), exports);
19
19
  __exportStar(require("./controllers/base-app.controller"), exports);
20
+ __exportStar(require("./decorators/current-user.decorator copy"), exports);
20
21
  __exportStar(require("./decorators/current-user.decorator"), exports);
21
22
  __exportStar(require("./filters/error-handler.filter"), exports);
22
23
  __exportStar(require("./guards/jwt-auth.guard"), exports);
23
24
  __exportStar(require("./helpers/bootstrap.helper"), exports);
24
25
  __exportStar(require("./helpers/swagger.helper"), exports);
25
26
  __exportStar(require("./interfaces/jwt-payload.interface"), exports);
27
+ __exportStar(require("./interfaces/user-payload.interface"), exports);
26
28
  __exportStar(require("./middlewares/logger.middleware"), exports);
29
+ __exportStar(require("./modules/base-auth.module"), exports);
27
30
  __exportStar(require("./strategies/base-jwt.strategy"), exports);
28
31
  __exportStar(require("./strategies/common-jwt.strategy"), exports);
29
32
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,qEAAmD;AACnD,+DAA6C;AAC7C,oEAAkD;AAClD,sEAAoD;AACpD,iEAA+C;AAC/C,0DAAwC;AACxC,6DAA2C;AAC3C,2DAAyC;AACzC,qEAAmD;AACnD,kEAAgD;AAChD,iEAA+C;AAC/C,mEAAiD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,qEAAmD;AACnD,+DAA6C;AAC7C,oEAAkD;AAClD,2EAAyD;AACzD,sEAAoD;AACpD,iEAA+C;AAC/C,0DAAwC;AACxC,6DAA2C;AAC3C,2DAAyC;AACzC,qEAAmD;AACnD,sEAAoD;AACpD,kEAAgD;AAChD,6DAA2C;AAC3C,iEAA+C;AAC/C,mEAAiD"}
@@ -0,0 +1,4 @@
1
+ export interface UserPayload {
2
+ sub: number;
3
+ email: string;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=user-payload.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-payload.interface.js","sourceRoot":"","sources":["../../src/interfaces/user-payload.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare class BaseAuthModule {
2
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.BaseAuthModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const passport_1 = require("@nestjs/passport");
12
+ const auth_strategy_constant_1 = require("../constants/auth-strategy.constant");
13
+ const common_jwt_strategy_1 = require("../strategies/common-jwt.strategy");
14
+ let BaseAuthModule = class BaseAuthModule {
15
+ };
16
+ exports.BaseAuthModule = BaseAuthModule;
17
+ exports.BaseAuthModule = BaseAuthModule = __decorate([
18
+ (0, common_1.Global)(),
19
+ (0, common_1.Module)({
20
+ imports: [passport_1.PassportModule.register({ defaultStrategy: auth_strategy_constant_1.AUTH_STRATEGY.JWT })],
21
+ providers: [common_jwt_strategy_1.CommonJwtStrategy],
22
+ exports: [passport_1.PassportModule, common_jwt_strategy_1.CommonJwtStrategy],
23
+ })
24
+ ], BaseAuthModule);
25
+ //# sourceMappingURL=base-auth.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-auth.module.js","sourceRoot":"","sources":["../../src/modules/base-auth.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,+CAAkD;AAClD,gFAAqE;AACrE,2EAAuE;AAQhE,IAAM,cAAc,GAApB,MAAM,cAAc;CAAG,CAAA;AAAjB,wCAAc;yBAAd,cAAc;IAN1B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,yBAAc,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,sCAAa,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1E,SAAS,EAAE,CAAC,uCAAiB,CAAC;QAC9B,OAAO,EAAE,CAAC,yBAAc,EAAE,uCAAiB,CAAC;KAC7C,CAAC;GACW,cAAc,CAAG"}
@@ -3,7 +3,7 @@ import { JwtPayload } from 'src/interfaces/jwt-payload.interface';
3
3
  export declare class CommonJwtStrategy extends BaseJwtStrategy {
4
4
  constructor();
5
5
  validate(payload: JwtPayload): Promise<{
6
- id: string;
6
+ sub: string;
7
7
  email: string;
8
8
  }>;
9
9
  }
@@ -21,7 +21,7 @@ let CommonJwtStrategy = class CommonJwtStrategy extends base_jwt_strategy_1.Base
21
21
  }
22
22
  async validate(payload) {
23
23
  return {
24
- id: payload.sub,
24
+ sub: payload.sub,
25
25
  email: payload.email,
26
26
  };
27
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"common-jwt.strategy.js","sourceRoot":"","sources":["../../src/strategies/common-jwt.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2DAAsD;AAI/C,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,mCAAe;IACpD;QACE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAmB;QAChC,OAAO;YACL,EAAE,EAAE,OAAO,CAAC,GAAG;YACf,KAAK,EAAE,OAAO,CAAC,KAAK;SAErB,CAAC;IACJ,CAAC;CACF,CAAA;AAfY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;;GACA,iBAAiB,CAe7B"}
1
+ {"version":3,"file":"common-jwt.strategy.js","sourceRoot":"","sources":["../../src/strategies/common-jwt.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2DAAsD;AAI/C,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,mCAAe;IACpD;QACE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAmB;QAChC,OAAO;YACL,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,KAAK,EAAE,OAAO,CAAC,KAAK;SAErB,CAAC;IACJ,CAAC;CACF,CAAA;AAfY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;;GACA,iBAAiB,CAe7B"}