Skip to content

Commit

Permalink
refactor: use ConfigService over process.env
Browse files Browse the repository at this point in the history
  • Loading branch information
Gi-jutsu committed Dec 6, 2024
1 parent 45b8630 commit 2649287
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ValidationPipe } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { NestFactory } from "@nestjs/core";
import cookieParser from "cookie-parser";
import helmet from "helmet";
Expand All @@ -12,9 +13,10 @@ export async function bootstrap() {
application.use(cookieParser());
application.useGlobalPipes(new ValidationPipe());

const host = process.env.API_HTTP_HOST || "127.0.0.1";
const port = process.env.API_HTTP_PORT || "8080";
const scheme = process.env.API_HTTP_SCHEME || "http";
const config = application.get(ConfigService);
const host = config.getOrThrow("API_HTTP_HOST");
const port = config.getOrThrow("API_HTTP_PORT");
const scheme = config.getOrThrow("API_HTTP_SCHEME");
const url = `${scheme}://${host}:${port}`;

await application.listen(port, host, () =>
Expand Down

0 comments on commit 2649287

Please sign in to comment.