@dryv/nestjsv0.6.0
NestJS feature controllers, services and modules for HTTP operations.
dryv pack add @dryv/nestjs{#- Imports every group module (Dryv members of this template) and, when generated entities are
in use through the persistence slot, the project's DatabaseModule. -#}
{%- macro has_slot(slot) -%}
{%- for dependency in file.dependencies -%}{%- if dependency.slot == slot -%}x{%- endif -%}{%- endfor -%}
{%- endmacro -%}
{%- set persistence = has_slot('schema.persistence') != '' -%}
import { Module } from "@nestjs/common";
import { APP_PIPE } from "@nestjs/core";
{%- if persistence %}
import { DatabaseModule } from "./database/database.module.ts";
{%- endif %}
{%- for dependency in file.dependencies %}{% if dependency.symbol and dependency.slot is none %}
import { {% if dependency.template == 'http-options' %}HttpValidationPipe, {% endif %}{{ dependency.symbol }} } from "{{ (dependency.path.prefixed or ('./' ~ dependency.path.relative)) }}";
{%- endif %}{% endfor %}
@Module({
imports: [
{%- if persistence %}
DatabaseModule,
{%- endif %}
{%- for dependency in file.dependencies %}{% if dependency.symbol and dependency.slot is none and dependency.template == 'group-module' %}
{{ dependency.symbol }},
{%- endif %}{% endfor %}
],
providers: [
{%- for dependency in file.dependencies %}{% if dependency.slot is none and dependency.template == 'http-options' %}
{ provide: APP_PIPE, useValue: new HttpValidationPipe({{ dependency.symbol }}) },
{%- endif %}{% endfor %}
],
})
export class {{ file.symbol }} {}