Using the variables
It's time to actually remove that data from the codebase and use it through environment variables.
TypeOrmModule.forRootAsync({
useFactory: () => ({
type: 'postgres',
url: process.env.DATABASE_URL,
autoLoadEntities: true,
}),
}),POSTGRES_PASSWORD: ${DATABASE_PASSWORD}ports:
- ${DATABASE_PORT}:5432import * as dotenv from 'dotenv';
import * as dotenvExpand from 'dotenv-expand';
dotenvExpand.expand(dotenv.config());
export default new DataSource({
// ...
url: process.env.DATABASE_URL,
// ...
});Last updated