-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aplicando configurações de environment
- Loading branch information
1 parent
1c9afc1
commit 97c2c29
Showing
10 changed files
with
63 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PORT= | ||
NODE_ENV= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PORT=3000 | ||
NODE_ENV=development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PORT=3000 | ||
NODE_ENV=test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/shared/infrastructure/env-config/__tests__/unit/env-config.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
import { EnvConfigService } from '../../env-config.service' | ||
import { EnvConfigModule } from '../../env-config.module' | ||
|
||
describe('EnvConfigService', () => { | ||
let sut: EnvConfigService | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
imports: [EnvConfigModule.forRoot()], | ||
providers: [EnvConfigService], | ||
}).compile() | ||
|
||
sut = module.get<EnvConfigService>(EnvConfigService) | ||
}) | ||
|
||
it('should be defined', () => { | ||
expect(sut).toBeDefined() | ||
}) | ||
|
||
it('deve retornar a variavel PORT', () => { | ||
expect(sut.getAppPort()).toBe(3000) | ||
}) | ||
|
||
it('deve retornar a variavel NODE_ENV', () => { | ||
expect(sut.getNodeEnv()).toBe('test') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,20 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { EnvConfigService } from './env-config.service'; | ||
import { DynamicModule, Module } from '@nestjs/common' | ||
import { EnvConfigService } from './env-config.service' | ||
import { ConfigModule, ConfigModuleOptions } from '@nestjs/config' | ||
import { join } from 'node:path' | ||
|
||
@Module({ | ||
providers: [EnvConfigService] | ||
providers: [EnvConfigService], | ||
exports: [EnvConfigService], | ||
}) | ||
export class EnvConfigModule {} | ||
export class EnvConfigModule extends ConfigModule { | ||
static forRoot(options: ConfigModuleOptions = {}): DynamicModule { | ||
return super.forRoot({ | ||
...options, | ||
envFilePath: [ | ||
// join(__dirname, `../../../../environment/.env`), | ||
join(__dirname, `../../../../environment/.env.${process.env.NODE_ENV}`), | ||
], | ||
}) | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
src/shared/infrastructure/env-config/env-config.service.spec.ts
This file was deleted.
Oops, something went wrong.