🔧 add @nestjs/config
This commit is contained in:
parent
376c0e7d65
commit
7ec188cec5
5
.gitignore
vendored
5
.gitignore
vendored
@ -32,4 +32,7 @@ lerna-debug.log*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
# environment variables
|
||||
.env
|
@ -17,6 +17,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^9.0.0",
|
||||
"@nestjs/config": "^2.3.1",
|
||||
"@nestjs/core": "^9.0.0",
|
||||
"@nestjs/platform-express": "^9.0.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
|
@ -3,6 +3,7 @@ lockfileVersion: 5.4
|
||||
specifiers:
|
||||
'@nestjs/cli': ^9.0.0
|
||||
'@nestjs/common': ^9.0.0
|
||||
'@nestjs/config': ^2.3.1
|
||||
'@nestjs/core': ^9.0.0
|
||||
'@nestjs/platform-express': ^9.0.0
|
||||
'@nestjs/schematics': ^9.0.0
|
||||
@ -27,6 +28,7 @@ specifiers:
|
||||
|
||||
dependencies:
|
||||
'@nestjs/common': 9.3.9_mnr6j2del53muneqly5h4y27ai
|
||||
'@nestjs/config': 2.3.1_jrq2rdgfp2sx67wmylmrqliwxe
|
||||
'@nestjs/core': 9.3.9_q6agyr4hwia55oswpsa7zjxcpm
|
||||
'@nestjs/platform-express': 9.3.9_77foi4w27ghy47yutmnzv7krjy
|
||||
reflect-metadata: 0.1.13
|
||||
@ -337,6 +339,22 @@ packages:
|
||||
uid: 2.0.1
|
||||
dev: false
|
||||
|
||||
/@nestjs/config/2.3.1_jrq2rdgfp2sx67wmylmrqliwxe:
|
||||
resolution: {integrity: sha512-Ckzel0NZ9CWhNsLfE1hxfDuxJuEbhQvGxSlmZ1/X8awjRmAA/g3kT6M1+MO1SHj1wMtPyUfd9WpwkiqFbiwQgA==}
|
||||
peerDependencies:
|
||||
'@nestjs/common': ^7.0.0 || ^8.0.0 || ^9.0.0
|
||||
reflect-metadata: ^0.1.13
|
||||
rxjs: ^6.0.0 || ^7.2.0
|
||||
dependencies:
|
||||
'@nestjs/common': 9.3.9_mnr6j2del53muneqly5h4y27ai
|
||||
dotenv: 16.0.3
|
||||
dotenv-expand: 10.0.0
|
||||
lodash: 4.17.21
|
||||
reflect-metadata: 0.1.13
|
||||
rxjs: 7.8.0
|
||||
uuid: 9.0.0
|
||||
dev: false
|
||||
|
||||
/@nestjs/core/9.3.9_q6agyr4hwia55oswpsa7zjxcpm:
|
||||
resolution: {integrity: sha512-9g1A1G9eirLXEpH21rc6dKb08zHc2+adhCRz8NW39hbejcsxxD72FApJzt4QBQAKvu862ixt/tdpStnFT7lOSw==}
|
||||
requiresBuild: true
|
||||
@ -1336,6 +1354,16 @@ packages:
|
||||
esutils: 2.0.3
|
||||
dev: true
|
||||
|
||||
/dotenv-expand/10.0.0:
|
||||
resolution: {integrity: sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==}
|
||||
engines: {node: '>=12'}
|
||||
dev: false
|
||||
|
||||
/dotenv/16.0.3:
|
||||
resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==}
|
||||
engines: {node: '>=12'}
|
||||
dev: false
|
||||
|
||||
/eastasianwidth/0.2.0:
|
||||
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
||||
dev: true
|
||||
@ -2240,7 +2268,6 @@ packages:
|
||||
|
||||
/lodash/4.17.21:
|
||||
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
||||
dev: true
|
||||
|
||||
/log-symbols/4.1.0:
|
||||
resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==}
|
||||
@ -3335,6 +3362,11 @@ packages:
|
||||
engines: {node: '>= 0.4.0'}
|
||||
dev: false
|
||||
|
||||
/uuid/9.0.0:
|
||||
resolution: {integrity: sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==}
|
||||
hasBin: true
|
||||
dev: false
|
||||
|
||||
/v8-compile-cache-lib/3.0.1:
|
||||
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
|
||||
dev: true
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { ConfigModule } from '@nestjs/config'
|
||||
import config from 'src/common/configs/config'
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
imports: [ConfigModule.forRoot({ isGlobal: true, load: [config] })],
|
||||
controllers: [],
|
||||
providers: [],
|
||||
})
|
||||
|
7
src/common/configs/config.interface.ts
Normal file
7
src/common/configs/config.interface.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export interface Config {
|
||||
nest: NestConfig
|
||||
}
|
||||
|
||||
export interface NestConfig {
|
||||
port: number
|
||||
}
|
9
src/common/configs/config.ts
Normal file
9
src/common/configs/config.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import type { Config } from './config.interface'
|
||||
|
||||
const config: Config = {
|
||||
nest: {
|
||||
port: parseInt(process.env.PORT) || 3000,
|
||||
},
|
||||
}
|
||||
|
||||
export default (): Config => config
|
Loading…
Reference in New Issue
Block a user