itlab-internal-services 1.4.4 → 1.5.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/internal.module.js
CHANGED
|
@@ -113,6 +113,7 @@ InternalModule = InternalModule_1 = __decorate([
|
|
|
113
113
|
services_1.CommentService,
|
|
114
114
|
services_1.ContentService,
|
|
115
115
|
services_1.SearchService,
|
|
116
|
+
services_1.AccountService,
|
|
116
117
|
{ provide: internal_constants_1.AXIOS_INSTANCE_TOKEN, useValue: axios_1.default },
|
|
117
118
|
{ provide: internal_constants_1.INTERNAL_MODULE_TARGET, useValue: '' },
|
|
118
119
|
{ provide: internal_constants_1.INTERNAL_MODULE_HEADER_TOKEN, useValue: '' },
|
|
@@ -120,7 +121,7 @@ InternalModule = InternalModule_1 = __decorate([
|
|
|
120
121
|
guards_1.JwtStrategy,
|
|
121
122
|
guards_1.InternalStrategy,
|
|
122
123
|
],
|
|
123
|
-
exports: [services_1.CommentService, services_1.ContentService, services_1.SearchService],
|
|
124
|
+
exports: [services_1.CommentService, services_1.ContentService, services_1.SearchService, services_1.AccountService],
|
|
124
125
|
})
|
|
125
126
|
], InternalModule);
|
|
126
127
|
exports.InternalModule = InternalModule;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export declare class AccountInformation {
|
|
3
|
+
id: string;
|
|
4
|
+
username: string;
|
|
5
|
+
email: string;
|
|
6
|
+
avatar?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class AccountService {
|
|
9
|
+
protected readonly instance: AxiosInstance;
|
|
10
|
+
constructor(instance?: AxiosInstance);
|
|
11
|
+
protected prefix: string;
|
|
12
|
+
create(accountId: string, email: string): Promise<void>;
|
|
13
|
+
get(accountId: string): Promise<AccountInformation>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.AccountService = exports.AccountInformation = void 0;
|
|
28
|
+
const common_1 = require("@nestjs/common");
|
|
29
|
+
const axios_1 = __importDefault(require("axios"));
|
|
30
|
+
const internal_constants_1 = require("../internal.constants");
|
|
31
|
+
class AccountInformation {
|
|
32
|
+
}
|
|
33
|
+
exports.AccountInformation = AccountInformation;
|
|
34
|
+
let AccountService = class AccountService {
|
|
35
|
+
constructor(instance = axios_1.default) {
|
|
36
|
+
this.instance = instance;
|
|
37
|
+
this.prefix = 'account';
|
|
38
|
+
}
|
|
39
|
+
create(accountId, email) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
this.instance
|
|
43
|
+
.post(`${this.prefix}/internal`, { accountId, email })
|
|
44
|
+
.then(() => resolve())
|
|
45
|
+
.catch(({ response }) => reject(new common_1.HttpException(response.data, response.status)));
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
get(accountId) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
this.instance
|
|
53
|
+
.get(`${this.prefix}/${accountId}`)
|
|
54
|
+
.then(({ data }) => resolve(data))
|
|
55
|
+
.catch(() => resolve({ username: 'NOT FOUND', id: '0', email: '' }));
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
AccountService = __decorate([
|
|
61
|
+
__param(0, (0, common_1.Inject)(internal_constants_1.AXIOS_INSTANCE_TOKEN)),
|
|
62
|
+
__metadata("design:paramtypes", [Function])
|
|
63
|
+
], AccountService);
|
|
64
|
+
exports.AccountService = AccountService;
|
package/dist/services/index.d.ts
CHANGED
package/dist/services/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./account.service"), exports);
|
|
17
18
|
__exportStar(require("./comment.service"), exports);
|
|
18
19
|
__exportStar(require("./content.service"), exports);
|
|
19
20
|
__exportStar(require("./search.service"), exports);
|