itlab-internal-services 1.0.0 → 1.0.1
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/guards/internal.guard.js +1 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal.module.js +2 -8
- package/dist/swagger.config.d.ts +11 -0
- package/dist/swagger.config.js +29 -0
- package/package.json +1 -1
|
@@ -24,8 +24,7 @@ let InternalGuard = class InternalGuard {
|
|
|
24
24
|
canActivate(ctx) {
|
|
25
25
|
if (this.headerToken.length === 0)
|
|
26
26
|
return false;
|
|
27
|
-
if (this.headerToken ===
|
|
28
|
-
ctx.switchToHttp().getRequest().header(exports.INTERNAL_HEADER_KEY))
|
|
27
|
+
if (this.headerToken === ctx.switchToHttp().getRequest().header(exports.INTERNAL_HEADER_KEY))
|
|
29
28
|
return true;
|
|
30
29
|
throw new UnauthorizedApplicationException();
|
|
31
30
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/internal.module.js
CHANGED
|
@@ -35,10 +35,7 @@ let InternalModule = InternalModule_1 = class InternalModule {
|
|
|
35
35
|
return {
|
|
36
36
|
module: InternalModule_1,
|
|
37
37
|
providers: [
|
|
38
|
-
{
|
|
39
|
-
provide: internal_constants_1.AXIOS_INSTANCE_TOKEN,
|
|
40
|
-
useValue: axios_1.default.create(axiosConfig(options)),
|
|
41
|
-
},
|
|
38
|
+
{ provide: internal_constants_1.AXIOS_INSTANCE_TOKEN, useValue: axios_1.default.create(axiosConfig(options)) },
|
|
42
39
|
{ provide: internal_constants_1.INTERNAL_MODULE_ID, useValue: (0, random_string_generator_util_1.randomStringGenerator)() },
|
|
43
40
|
{ provide: internal_constants_1.INTERNAL_MODULE_TARGET, useValue: options.target },
|
|
44
41
|
{ provide: internal_constants_1.INTERNAL_MODULE_HEADER_TOKEN, useValue: options.token },
|
|
@@ -92,10 +89,7 @@ let InternalModule = InternalModule_1 = class InternalModule {
|
|
|
92
89
|
}
|
|
93
90
|
return [
|
|
94
91
|
this.createAsyncOptionsProvider(options),
|
|
95
|
-
{
|
|
96
|
-
provide: options.useClass,
|
|
97
|
-
useClass: options.useClass,
|
|
98
|
-
},
|
|
92
|
+
{ provide: options.useClass, useClass: options.useClass },
|
|
99
93
|
];
|
|
100
94
|
}
|
|
101
95
|
static createAsyncOptionsProvider(options) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DocumentBuilder, OpenAPIObject } from '@nestjs/swagger';
|
|
2
|
+
export interface SwaggerOptions {
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
jwt?: boolean;
|
|
6
|
+
k8s?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare type SwaggerConfig = Omit<OpenAPIObject, 'paths'>;
|
|
9
|
+
export declare function getSwaggerConfig(options?: SwaggerOptions): SwaggerConfig;
|
|
10
|
+
export declare function getSwaggerDocument(options?: SwaggerOptions): DocumentBuilder;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSwaggerDocument = exports.getSwaggerConfig = void 0;
|
|
4
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
5
|
+
const guards_1 = require("./guards");
|
|
6
|
+
function getSwaggerConfig(options) {
|
|
7
|
+
return getSwaggerDocument(options).build();
|
|
8
|
+
}
|
|
9
|
+
exports.getSwaggerConfig = getSwaggerConfig;
|
|
10
|
+
function getSwaggerDocument(options) {
|
|
11
|
+
let cfg = new swagger_1.DocumentBuilder();
|
|
12
|
+
cfg = cfg.setContact('Timo Scheuermann', '', 'timo.scheuermann@sv-informatik.de');
|
|
13
|
+
cfg = cfg.setTitle(options.title);
|
|
14
|
+
cfg = cfg.setDescription(options.description);
|
|
15
|
+
cfg = cfg.addServer(process.env.SWAGGER_BASE_PATH || 'http://localhost:3000');
|
|
16
|
+
if (options && options.jwt === true) {
|
|
17
|
+
cfg = cfg.addBearerAuth({
|
|
18
|
+
in: 'header',
|
|
19
|
+
type: 'http',
|
|
20
|
+
bearerFormat: 'JWT',
|
|
21
|
+
description: 'Gesicherter Login Token',
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (options && options.k8s === true) {
|
|
25
|
+
cfg = cfg.addApiKey({ in: 'header', type: 'apiKey', description: 'Token zur Authentifizierung interner Anrufe' }, guards_1.INTERNAL_HEADER_KEY);
|
|
26
|
+
}
|
|
27
|
+
return cfg;
|
|
28
|
+
}
|
|
29
|
+
exports.getSwaggerDocument = getSwaggerDocument;
|