@uniorganization/uni-lib 1.0.2 → 1.0.6
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/config/db.config.js +2 -2
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +1 -0
- package/dist/config/swagger.config.d.ts +1 -0
- package/dist/config/swagger.config.js +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/modules/auth.module.d.ts +0 -0
- package/dist/modules/auth.module.js +0 -0
- package/dist/modules/common/common.module.d.ts +2 -0
- package/dist/modules/common/common.module.js +28 -0
- package/dist/modules/common/index.d.ts +3 -0
- package/dist/modules/common/index.js +15 -0
- package/dist/modules/common/jwt-auth.guard.d.ts +5 -0
- package/dist/modules/common/jwt-auth.guard.js +26 -0
- package/dist/modules/common/jwt.strategy.d.ts +9 -0
- package/dist/modules/common/jwt.strategy.js +43 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +13 -0
- package/package.json +8 -1
package/dist/config/db.config.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypeOrmConfigService = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
-
const config_entity_1 = require("
|
|
6
|
-
const vw_escalation_age_1 = require("
|
|
5
|
+
const config_entity_1 = require("../entities/config.entity");
|
|
6
|
+
const vw_escalation_age_1 = require("../entities/vw-escalation-age");
|
|
7
7
|
class TypeOrmConfigService {
|
|
8
8
|
createTypeOrmOptions() {
|
|
9
9
|
return {
|
package/dist/config/index.d.ts
CHANGED
package/dist/config/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setUpSwagger(app: any): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setUpSwagger = void 0;
|
|
4
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
5
|
+
function setUpSwagger(app) {
|
|
6
|
+
const options = new swagger_1.DocumentBuilder()
|
|
7
|
+
.setTitle('UNI')
|
|
8
|
+
.setDescription('UNI API')
|
|
9
|
+
.setVersion('1.0.0')
|
|
10
|
+
.build();
|
|
11
|
+
const document = swagger_1.SwaggerModule.createDocument(app, options);
|
|
12
|
+
swagger_1.SwaggerModule.setup('api', app, document);
|
|
13
|
+
}
|
|
14
|
+
exports.setUpSwagger = setUpSwagger;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
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.CommonModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const passport_1 = require("@nestjs/passport");
|
|
12
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
13
|
+
const jwt_strategy_1 = require("./jwt.strategy");
|
|
14
|
+
let CommonModule = class CommonModule {
|
|
15
|
+
};
|
|
16
|
+
CommonModule = __decorate([
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
imports: [
|
|
19
|
+
passport_1.PassportModule,
|
|
20
|
+
jwt_1.JwtModule.register({
|
|
21
|
+
secret: process.env.JWT_SECRET,
|
|
22
|
+
signOptions: { expiresIn: '12h' },
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
providers: [jwt_strategy_1.JwtStrategy],
|
|
26
|
+
})
|
|
27
|
+
], CommonModule);
|
|
28
|
+
exports.CommonModule = CommonModule;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./common.module"), exports);
|
|
14
|
+
__exportStar(require("./jwt-auth.guard"), exports);
|
|
15
|
+
__exportStar(require("./jwt.strategy"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
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.JwtAuthGuard = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const passport_1 = require("@nestjs/passport");
|
|
12
|
+
let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
|
|
13
|
+
handleRequest(err, user, info) {
|
|
14
|
+
const enableJWT = JSON.parse(process.env.JWT_ENABLE);
|
|
15
|
+
if (enableJWT) {
|
|
16
|
+
if (err || !user) {
|
|
17
|
+
throw err || new common_1.UnauthorizedException();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return user;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
JwtAuthGuard = __decorate([
|
|
24
|
+
(0, common_1.Injectable)()
|
|
25
|
+
], JwtAuthGuard);
|
|
26
|
+
exports.JwtAuthGuard = JwtAuthGuard;
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.JwtStrategy = void 0;
|
|
22
|
+
const common_1 = require("@nestjs/common");
|
|
23
|
+
const passport_1 = require("@nestjs/passport");
|
|
24
|
+
const passport_jwt_1 = require("passport-jwt");
|
|
25
|
+
let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
|
|
26
|
+
constructor() {
|
|
27
|
+
super({
|
|
28
|
+
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
29
|
+
ignoreExpiration: JSON.parse(process.env.JWT_IGNORE_EXPIRATION) || false,
|
|
30
|
+
secretOrKey: process.env.JWT_SECRET,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
validate(payload) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
return { payload };
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
JwtStrategy = __decorate([
|
|
40
|
+
(0, common_1.Injectable)(),
|
|
41
|
+
__metadata("design:paramtypes", [])
|
|
42
|
+
], JwtStrategy);
|
|
43
|
+
exports.JwtStrategy = JwtStrategy;
|
package/dist/modules/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './common';
|
package/dist/modules/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./common"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniorganization/uni-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "UNI Library",
|
|
5
5
|
"author": "Jhomiguel",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,6 +24,12 @@
|
|
|
24
24
|
"@nestjs/common": "^8.2.3"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
+
"@nestjs/jwt": "^8.0.0",
|
|
28
|
+
"@nestjs/passport": "^8.0.1",
|
|
29
|
+
"@nestjs/swagger": "^5.1.5",
|
|
30
|
+
"passport": "^0.5.0",
|
|
31
|
+
"passport-jwt": "^4.0.0",
|
|
32
|
+
"swagger-ui-express": "^4.1.6",
|
|
27
33
|
"typeorm": "^0.2.41"
|
|
28
34
|
},
|
|
29
35
|
"devDependencies": {
|
|
@@ -36,6 +42,7 @@
|
|
|
36
42
|
"@types/express": "4.16.1",
|
|
37
43
|
"@types/jest": "^26.0.22",
|
|
38
44
|
"@types/node": "^14.14.36",
|
|
45
|
+
"@types/passport-jwt": "^3.0.6",
|
|
39
46
|
"@types/supertest": "^2.0.10",
|
|
40
47
|
"jest": "^26.6.3",
|
|
41
48
|
"prettier": "^2.2.1",
|