refactor: reorganize environment configurations by replacing global .env with environment-specific files and updating npm scripts accordingly

This commit is contained in:
azeeee05
2026-07-09 14:39:05 +05:30
parent 4441fa2cce
commit 18454d5197
4 changed files with 47 additions and 33 deletions
View File
+10
View File
@@ -0,0 +1,10 @@
DB_HOST=106.51.105.22
DB_PORT=5432
DB_NAME=ar_uat
DB_USER=ar_user
DB_PASSWORD="V$:Q1Hc6Qh]@#Fr"
DB_SYNCHRONIZE=true
DB_SSL=false
PORT=9501
CORS_ORIGIN=https://aruat.maskantech.in
NODE_ENV=uat
+29 -32
View File
@@ -18,46 +18,43 @@ This is the backend REST API powered by NestJS.
npm install
```
### Environment files
The project uses environment-specific files:
- .env
- .env.dev
- .env.test
### Environment Files
The npm scripts automatically set NODE_ENV so the correct file is used.
The project uses environment-specific files. The npm scripts automatically set `NODE_ENV` so the correct file is loaded (e.g. `.env.dev`).
- `.env.local`
- `.env.dev`
- `.env.uat`
- `.env.test`
### Running the Application
To start the server, use the command corresponding to your target environment:
### Run locally
Start the local development server:
```bash
npm run start
```
# Local environment
npm run local
npm run start:local # (watch mode)
Start the development server in watch mode:
```bash
# Development environment
npm run dev
```
npm run start:dev # (watch mode)
### Run tests
Run the test suite with the test environment:
```bash
# UAT environment
npm run uat
npm run start:uat # (watch mode)
# Test environment
npm run test
```
### Build commands
Build for development:
```bash
npm run build:dev
```
### Database Seeding
Build for test:
```bash
npm run build:test
```
To run the master data seed scripts for a specific environment:
### Useful scripts
- npm run start - starts the app using the local development environment
- npm run dev - starts the app using .env.dev
- npm test - runs tests using .env.test
- npm run build - builds the app for development
- npm run build:dev - explicit development build
- npm run build:test - explicit test build
```bash
npm run seed:local
npm run seed:dev
npm run seed:uat
npm run seed:test
```
+8 -1
View File
@@ -7,10 +7,17 @@
"license": "UNLICENSED",
"scripts": {
"dev": "cross-env NODE_ENV=dev nest start",
"seed": "cross-env NODE_ENV=dev ts-node -r tsconfig-paths/register scripts/seed-master-data.ts",
"uat": "cross-env NODE_ENV=uat nest start",
"local": "cross-env NODE_ENV=local nest start",
"seed:dev": "cross-env NODE_ENV=dev ts-node -r tsconfig-paths/register scripts/seed-master-data.ts",
"seed:local": "cross-env NODE_ENV=local ts-node -r tsconfig-paths/register scripts/seed-master-data.ts",
"seed:uat": "cross-env NODE_ENV=uat ts-node -r tsconfig-paths/register scripts/seed-master-data.ts",
"seed:test": "cross-env NODE_ENV=test ts-node -r tsconfig-paths/register scripts/seed-master-data.ts",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "cross-env NODE_ENV=dev nest start --watch",
"start:uat": "cross-env NODE_ENV=uat nest start --watch",
"start:local": "cross-env NODE_ENV=local nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",