nest-translate
Version:
基于 nestjs 封装的翻译 API
46 lines (45 loc) • 2.03 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 TranslateBaiduModule_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TranslateBaiduModule = void 0;
const common_1 = require("@nestjs/common");
const translate_constants_1 = require("./translate.constants");
const baidu_service_1 = require("./baidu.service");
let TranslateBaiduModule = TranslateBaiduModule_1 = class TranslateBaiduModule {
static forRoot(options) {
return {
module: TranslateBaiduModule_1,
providers: [
{
provide: translate_constants_1.BAIDU_APP_OPTIONS,
useValue: options
},
baidu_service_1.TranslateBaiduService
],
exports: [baidu_service_1.TranslateBaiduService]
};
}
static forRootAsync(options) {
return {
module: TranslateBaiduModule_1,
imports: options.imports || [],
providers: [this.createAsyncOptions(options), baidu_service_1.TranslateBaiduService],
exports: [baidu_service_1.TranslateBaiduService]
};
}
};
TranslateBaiduModule.createAsyncOptions = (options) => ({
provide: translate_constants_1.BAIDU_APP_OPTIONS,
useFactory: options.useFactory,
inject: options.inject
});
TranslateBaiduModule = TranslateBaiduModule_1 = __decorate([
(0, common_1.Module)({})
], TranslateBaiduModule);
exports.TranslateBaiduModule = TranslateBaiduModule;