move database configs to .env
This commit is contained in:
@@ -2,4 +2,7 @@ ENV=development
|
||||
PORT=5000
|
||||
SECRET=aE8efkEP8+V/ibEQl8IKbw==
|
||||
|
||||
DB_NAME=todoListDev
|
||||
DB_HOST=localhost
|
||||
DB_USER=postgres
|
||||
DB_PASSWORD=postgres
|
||||
DB_NAME=todoListDev
|
||||
|
||||
@@ -2,4 +2,7 @@ ENV=test
|
||||
PORT=5000
|
||||
SECRET=aE8efkEP8+V/ibEQl8IKbw==
|
||||
|
||||
DB_NAME=todoListTest
|
||||
DB_HOST=localhost
|
||||
DB_USER=postgres
|
||||
DB_PASSWORD=postgres
|
||||
DB_NAME=todoListTest
|
||||
|
||||
3
server/src/env.d.ts
vendored
3
server/src/env.d.ts
vendored
@@ -1,5 +1,8 @@
|
||||
declare namespace NodeJS {
|
||||
interface ProcessEnv {
|
||||
DB_HOST?: string;
|
||||
DB_USER?: string;
|
||||
DB_PASSWORD?: string;
|
||||
DB_NAME?: string;
|
||||
NODE_ENV?: 'test' | 'development' | 'production';
|
||||
}
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
import * as dotenv from "dotenv";
|
||||
import "reflect-metadata";
|
||||
import { DataSource } from "typeorm";
|
||||
import { Project } from "../entity/project.entity";
|
||||
import { Task } from '../entity/task.entity';
|
||||
import { Task } from "../entity/task.entity";
|
||||
import { User } from "../entity/user.entity";
|
||||
|
||||
dotenv.config();
|
||||
dotenv.config({
|
||||
path: process.env.NODE_ENV === "test" ? ".env.test" : ".env",
|
||||
});
|
||||
|
||||
export const AppDataSource = new DataSource({
|
||||
type: "postgres",
|
||||
host: "localhost",
|
||||
port: 5432,
|
||||
username: "joao",
|
||||
database: process.env.DB_NAME,
|
||||
synchronize: true,
|
||||
logging: false,
|
||||
entities: [User, Project, Task],
|
||||
migrations: [],
|
||||
subscribers: [],
|
||||
})
|
||||
type: "postgres",
|
||||
host: process.env.DB_HOST,
|
||||
port: 5432,
|
||||
username: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
synchronize: true,
|
||||
logging: false,
|
||||
entities: [User, Project, Task],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user