Nx: Nest schematic should setup @nestjs/config

Created on 4 Jun 2020  路  2Comments  路  Source: nrwl/nx

Description


Currently, the Nest schematic generates environment.ts files (because it extends the Node schematic). However, there is no explanation in the docs how to use the environment.ts files.
The generation of env.ts files by the schematic implies that we should be using custom config files in Nest and not *.env files: https://docs.nestjs.com/techniques/configuration#custom-configuration-files

The ask is that the schematic sets up nestjs/config to use the generated environment.ts files.
(happy to open a PR for this if solution is acceptable)

Motivation


Bring config management inline with how Angular manages configs.

Suggested Implementaion


import { ConfigModule } from '@nestjs/config'; import { environment } from '../environments/environment'; ... imports: [ ConfigModule.forRoot({ load: [() => environment], isGlobal: true }), ],

Alternate Implementations

community node feature

All 2 comments

This seems like a great feature! Would be happy to accept a PR! :+1:

Before this issue gets fixed I'm asking this here:
I'm progressively moving projects inside a NX repo. I'm stuck for a Nestjs project. We use config files in a config folder and we include them using:
ConfigModule.load(resolve(__dirname, "config", "**", "!(*.d).{ts,js}")),
The problem is: the config folder is not present in the dist directory when I use nx serve. Do you have a quick fix for this? A configuration so the src/config folder gets transpiled? I think the Asset folder has a similar behavior but I have no idea how to do it 馃槵 .
Thanks !

Was this page helpful?
0 / 5 - 0 ratings