UNPKG

@ackplus/nest-dynamic-templates

Version:

A powerful and flexible dynamic template rendering library for NestJS applications with support for Nunjucks, Handlebars, EJS, Pug, MJML, Markdown, and more.

84 lines 4.08 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 NestDynamicTemplatesModule_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.NestDynamicTemplatesModule = void 0; const common_1 = require("@nestjs/common"); const typeorm_1 = require("@nestjs/typeorm"); const template_entity_1 = require("./entities/template.entity"); const template_layout_entity_1 = require("./entities/template-layout.entity"); const template_engine_registry_1 = require("./services/template-engine.registry"); const template_layout_service_1 = require("./services/template-layout.service"); const template_service_1 = require("./services/template.service"); const template_config_service_1 = require("./services/template-config.service"); const constant_1 = require("./constant"); const resolve_config_1 = require("./config/resolve-config"); const SERVICES = [ template_config_service_1.TemplateConfigService, template_engine_registry_1.TemplateEngineRegistryService, template_layout_service_1.TemplateLayoutService, template_service_1.TemplateService, ]; const EXPORTS = [ template_config_service_1.TemplateConfigService, template_service_1.TemplateService, template_layout_service_1.TemplateLayoutService, template_engine_registry_1.TemplateEngineRegistryService, ]; const ENTITIES = typeorm_1.TypeOrmModule.forFeature([template_entity_1.NestDynamicTemplate, template_layout_entity_1.NestDynamicTemplateLayout]); let NestDynamicTemplatesModule = NestDynamicTemplatesModule_1 = class NestDynamicTemplatesModule { static forRoot(config = {}) { const resolved = (0, resolve_config_1.resolveConfig)(config); return { module: NestDynamicTemplatesModule_1, global: resolved.isGlobal, imports: [ENTITIES], providers: [ { provide: constant_1.NEST_DYNAMIC_TEMPLATES_OPTIONS, useValue: resolved }, ...SERVICES, ], exports: EXPORTS, }; } static forRootAsync(options) { return { module: NestDynamicTemplatesModule_1, global: options.isGlobal, imports: [ENTITIES, ...(options.imports || [])], providers: [...this.createAsyncOptionsProviders(options), ...SERVICES], exports: EXPORTS, }; } static createAsyncOptionsProviders(options) { if (options.useFactory) { return [ { provide: constant_1.NEST_DYNAMIC_TEMPLATES_OPTIONS, useFactory: async (...args) => (0, resolve_config_1.resolveConfig)(await options.useFactory(...args)), inject: options.inject || [], }, ]; } const providers = [ { provide: constant_1.NEST_DYNAMIC_TEMPLATES_OPTIONS, useFactory: async (factory) => (0, resolve_config_1.resolveConfig)(await factory.createNestDynamicTemplatesModuleOptions()), inject: [options.useExisting || options.useClass], }, ]; if (options.useClass) { providers.push({ provide: options.useClass, useClass: options.useClass }); } return providers; } }; exports.NestDynamicTemplatesModule = NestDynamicTemplatesModule; exports.NestDynamicTemplatesModule = NestDynamicTemplatesModule = NestDynamicTemplatesModule_1 = __decorate([ (0, common_1.Module)({}) ], NestDynamicTemplatesModule); //# sourceMappingURL=nest-dynamic-templates.module.js.map