itlab-internal-services 1.2.0 → 1.2.2
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/internal.module.js
CHANGED
|
@@ -26,7 +26,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
26
26
|
const guards_1 = require("./guards");
|
|
27
27
|
const internal_constants_1 = require("./internal.constants");
|
|
28
28
|
const services_1 = require("./services");
|
|
29
|
-
const
|
|
29
|
+
const getAxiosInstance = (config) => axios_1.default.create({
|
|
30
30
|
baseURL: 'https://services.svi-itlab.com/',
|
|
31
31
|
headers: { 'X-itlab-k8s-auth': config.token },
|
|
32
32
|
});
|
|
@@ -35,7 +35,7 @@ let InternalModule = InternalModule_1 = class InternalModule {
|
|
|
35
35
|
return {
|
|
36
36
|
module: InternalModule_1,
|
|
37
37
|
providers: [
|
|
38
|
-
{ provide: internal_constants_1.AXIOS_INSTANCE_TOKEN, useValue:
|
|
38
|
+
{ provide: internal_constants_1.AXIOS_INSTANCE_TOKEN, useValue: getAxiosInstance(options) },
|
|
39
39
|
{ provide: internal_constants_1.INTERNAL_MODULE_ID, useValue: (0, random_string_generator_util_1.randomStringGenerator)() },
|
|
40
40
|
{ provide: internal_constants_1.INTERNAL_MODULE_TARGET, useValue: options.target },
|
|
41
41
|
{ provide: internal_constants_1.INTERNAL_MODULE_HEADER_TOKEN, useValue: options.token },
|
|
@@ -51,7 +51,7 @@ let InternalModule = InternalModule_1 = class InternalModule {
|
|
|
51
51
|
...this.createAsyncProviders(options),
|
|
52
52
|
{
|
|
53
53
|
provide: internal_constants_1.AXIOS_INSTANCE_TOKEN,
|
|
54
|
-
useFactory: (config) =>
|
|
54
|
+
useFactory: (config) => getAxiosInstance(config),
|
|
55
55
|
inject: [internal_constants_1.INTERNAL_MODULE_OPTIONS],
|
|
56
56
|
},
|
|
57
57
|
{
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import { Targets } from '../pipes/target.pipe';
|
|
3
|
-
export declare
|
|
3
|
+
export declare class Comment {
|
|
4
|
+
authorId: string;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
html: string;
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
4
9
|
export declare class CommentService {
|
|
5
10
|
protected readonly instance: AxiosInstance;
|
|
6
11
|
protected readonly target: Targets;
|
|
@@ -8,4 +13,5 @@ export declare class CommentService {
|
|
|
8
13
|
protected prefix: string;
|
|
9
14
|
post(targetId: string, authorId: string, comment: Comment): Promise<Comment>;
|
|
10
15
|
delete(targetId: string): Promise<void>;
|
|
16
|
+
get(targetId: string): Promise<Comment[]>;
|
|
11
17
|
}
|
|
@@ -24,11 +24,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.CommentService = void 0;
|
|
27
|
+
exports.CommentService = exports.Comment = void 0;
|
|
28
28
|
const common_1 = require("@nestjs/common");
|
|
29
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
29
30
|
const axios_1 = __importDefault(require("axios"));
|
|
30
31
|
const internal_constants_1 = require("../internal.constants");
|
|
31
32
|
const target_pipe_1 = require("../pipes/target.pipe");
|
|
33
|
+
class Comment {
|
|
34
|
+
}
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, swagger_1.ApiProperty)(),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], Comment.prototype, "authorId", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, swagger_1.ApiProperty)(),
|
|
41
|
+
__metadata("design:type", Number)
|
|
42
|
+
], Comment.prototype, "timestamp", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, swagger_1.ApiProperty)(),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], Comment.prototype, "html", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, swagger_1.ApiProperty)({ maxLength: 50 }),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], Comment.prototype, "text", void 0);
|
|
51
|
+
exports.Comment = Comment;
|
|
32
52
|
let CommentService = class CommentService {
|
|
33
53
|
constructor(instance = axios_1.default, target = target_pipe_1.Targets.UNKNOWN) {
|
|
34
54
|
this.instance = instance;
|
|
@@ -55,6 +75,16 @@ let CommentService = class CommentService {
|
|
|
55
75
|
});
|
|
56
76
|
});
|
|
57
77
|
}
|
|
78
|
+
get(targetId) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
this.instance
|
|
82
|
+
.get(`${this.prefix}/${this.target}/${targetId}`)
|
|
83
|
+
.then(({ data }) => resolve(data))
|
|
84
|
+
.catch(({ response }) => reject(new common_1.HttpException(response.data, response.status)));
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
58
88
|
};
|
|
59
89
|
CommentService = __decorate([
|
|
60
90
|
__param(0, (0, common_1.Inject)(internal_constants_1.AXIOS_INSTANCE_TOKEN)),
|
|
@@ -65,6 +65,16 @@ let ContentService = class ContentService {
|
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
+
get(targetId) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
this.instance
|
|
72
|
+
.get(`${this.prefix}/${this.target}/${targetId}`)
|
|
73
|
+
.then(({ data }) => resolve(data))
|
|
74
|
+
.catch(({ response }) => reject(new common_1.HttpException(response.data, response.status)));
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
68
78
|
};
|
|
69
79
|
ContentService = __decorate([
|
|
70
80
|
__param(0, (0, common_1.Inject)(internal_constants_1.AXIOS_INSTANCE_TOKEN)),
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"email": "timo.scheuermann@sv-informatik.de",
|
|
6
6
|
"url": "https://timos.design"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.2.
|
|
8
|
+
"version": "1.2.2",
|
|
9
9
|
"type": "commonjs",
|
|
10
10
|
"files": [
|
|
11
11
|
"dist"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"prepack": "npm run build"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"axios": "1.
|
|
25
|
+
"axios": "^1.2.3",
|
|
26
26
|
"itlab-functions": "^0.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|