This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
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.
feat(user): add configuration module
- Loading branch information
1 parent
28cca96
commit 13818bf
Showing
12 changed files
with
224 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
dist | ||
*.css.d.ts | ||
*.css.d.ts | ||
back/.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,8 @@ | ||
NODE_ENV=development | ||
APP_SECRET=NotSoSecret | ||
|
||
DB_HOST=localhost | ||
DB_PORT=3306 | ||
DB_USER=admin | ||
DB_PASSWORD=admin | ||
DB_NAME=checkmoney |
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
File renamed without changes.
File renamed without changes.
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,24 @@ | ||
import { Provider } from '@nestjs/common' | ||
import { DotEnvConfiguration, EnvConfiguration } from '@solid-soda/config' | ||
import * as path from 'path' | ||
|
||
import { Configuration } from './Configuration' | ||
|
||
const isDev = () => process.env.NODE_ENV === 'development' | ||
|
||
export default class ConfigurationFactory { | ||
public static create(): Configuration { | ||
if (isDev()) { | ||
return new DotEnvConfiguration(path.resolve(__dirname, '../../.env')) | ||
} | ||
|
||
return new EnvConfiguration() | ||
} | ||
|
||
public static provider(): Provider { | ||
return { | ||
provide: Configuration, | ||
useValue: ConfigurationFactory.create(), | ||
} | ||
} | ||
} |
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 @@ | ||
export { AbstractConfiguration as Configuration } from '@solid-soda/config' |
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,11 @@ | ||
import { Module } from '@nestjs/common' | ||
|
||
import ConfigurationFactory from './ConfigationFactory' | ||
|
||
const configProvider = ConfigurationFactory.provider() | ||
|
||
@Module({ | ||
providers: [configProvider], | ||
exports: [configProvider], | ||
}) | ||
export class ConfigModule {} |
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
Oops, something went wrong.