Skip to content

Commit

Permalink
로컬/샌박 환경 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
minkj1992 committed Jan 22, 2021
1 parent b3a1cd8 commit a7f21f1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/config/config.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ConfigService } from "./config.service";
providers: [
{
provide: ConfigService,
useValue: new ConfigService(".env.dev"),
useValue: new ConfigService(),
},
],
exports: [ConfigService],
Expand Down
5 changes: 3 additions & 2 deletions src/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import * as fs from "fs";
export class ConfigService {
private readonly envConfig: { [key: string]: string };

constructor(filePath: string) {
console.log(`제민욱${process.env.NODE_ENV}`);
constructor() {
console.log(`${process.env.NODE_ENV}`);

if (process.env.NODE_ENV === "prod") {
this.envConfig = {
Expand All @@ -24,6 +24,7 @@ export class ConfigService {
MONGO_CACHE_NAME: process.env.MONGO_CACHE_NAME,
};
} else {
const filePath = ".env.dev";
this.envConfig = dotenv.parse(fs.readFileSync(filePath));
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ async function bootstrap() {
logger: ["error", "warn"],
});

const configService = new ConfigService(".env.dev");
const configService = new ConfigService();

app.enableCors();
// app.setGlobalPrefix(configService.get("NODE_ENV"));

await app.listen(process.env.PORT || configService.get("NODE_PORT"));
console.log(`Application is running on: ${await app.getUrl()}`);
}
Expand Down

0 comments on commit a7f21f1

Please sign in to comment.