question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nest schematic should setup @nestjs/config

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

8reactions
Samoxcommented, Jun 18, 2020

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 !

3reactions
JalilArfaouicommented, Mar 17, 2021

I miss this issue !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration | NestJS - A progressive Node.js framework
A good approach for using this technique in Nest is to create a ConfigModule that exposes a ConfigService which loads the appropriate .env...
Read more >
NestJS Config Module: Using environment variables - Tom Ray
Learn how to use environment variables (and other configuration values) in your NestJS projects with the Config Module.
Read more >
Config File Setup In NestJs - Abiral Sthapit - Medium
Create a . env file in the src of the application and lets assume we have following environment variables.
Read more >
node.js - How would you pass a property from a nest service ...
I finally passed my properties as nodejs globals in my config service. @Injectable() export class AppConfigService { get port(): number ...
Read more >
nest-typed-config - npm
Nest -typed-config will install the dependencies for all loaders by default. ... such as the official configuration module, nestjs-config and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found