UNPKG

rotowire-api-client

Version:

Node and NestJS wrappers for Rotowire feeds

75 lines 3 kB
"use strict"; 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 __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var ApiModule_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.ApiModule = void 0; const common_1 = require("@nestjs/common"); const axios_1 = require("@nestjs/axios"); const configuration_1 = require("./configuration"); const default_service_1 = require("./api/default.service"); let ApiModule = ApiModule_1 = class ApiModule { static forRoot(configurationFactory) { return { module: ApiModule_1, providers: [{ provide: configuration_1.Configuration, useFactory: configurationFactory }] }; } static forRootAsync(options) { const providers = [...this.createAsyncProviders(options)]; return { module: ApiModule_1, imports: options.imports || [], providers, exports: providers, }; } static createAsyncProviders(options) { if (options.useExisting || options.useFactory) { return [this.createAsyncConfigurationProvider(options)]; } return [ this.createAsyncConfigurationProvider(options), { provide: options.useClass, useClass: options.useClass, }, ]; } static createAsyncConfigurationProvider(options) { if (options.useFactory) { return { provide: configuration_1.Configuration, useFactory: options.useFactory, inject: options.inject || [], }; } return { provide: configuration_1.Configuration, useFactory: async (optionsFactory) => await optionsFactory.createConfiguration(), inject: [options.useExisting || options.useClass], }; } constructor(httpService) { } }; exports.ApiModule = ApiModule; exports.ApiModule = ApiModule = ApiModule_1 = __decorate([ (0, common_1.Module)({ imports: [axios_1.HttpModule], exports: [ default_service_1.DefaultRotowireMlbApiService ], providers: [ default_service_1.DefaultRotowireMlbApiService ] }), __metadata("design:paramtypes", [axios_1.HttpService]) ], ApiModule); //# sourceMappingURL=api.module.js.map