termii-nestjs
Version:
A NestJS SDK for Termii API
66 lines • 2.91 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var TermiiModule_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TermiiModule = void 0;
const common_1 = require("@nestjs/common");
const constants_1 = require("./common/constants");
const axios_1 = require("@nestjs/axios");
const messaging_service_1 = require("./messaging/messaging.service");
const token_service_1 = require("./token/token.service");
const insight_service_1 = require("./insight/insight.service");
const termii_service_1 = require("./termii.service");
let TermiiModule = TermiiModule_1 = class TermiiModule {
static forRoot(options) {
return {
module: TermiiModule_1,
providers: [
{
provide: constants_1.TERMII_MODULE_OPTIONS,
useValue: options,
},
],
};
}
static forRootAsync(options) {
return {
module: TermiiModule_1,
imports: options.imports || [],
providers: [...this.createAsyncProviders(options)],
};
}
static createAsyncProviders(options) {
if (options.useFactory) {
return [this.createAsyncOptionsProvider(options)];
}
const useExisting = options.useExisting;
const useClass = options.useClass;
return [
this.createAsyncOptionsProvider(options),
...(useClass ? [{ provide: useClass, useClass }] : []),
...(useExisting ? [{ provide: useExisting, useExisting }] : []),
];
}
static createAsyncOptionsProvider(options) {
return {
provide: constants_1.TERMII_MODULE_OPTIONS,
useFactory: options.useFactory,
inject: options.inject || [],
};
}
};
exports.TermiiModule = TermiiModule;
exports.TermiiModule = TermiiModule = TermiiModule_1 = __decorate([
(0, common_1.Global)(),
(0, common_1.Module)({
imports: [axios_1.HttpModule],
providers: [messaging_service_1.MessagingService, token_service_1.TokenService, insight_service_1.InsightService, termii_service_1.TermiiService],
exports: [messaging_service_1.MessagingService, token_service_1.TokenService, insight_service_1.InsightService, termii_service_1.TermiiService],
})
], TermiiModule);
//# sourceMappingURL=termii.module.js.map