Skip to content

Commit

Permalink
refactor: extract PORT as env var
Browse files Browse the repository at this point in the history
  • Loading branch information
saifali96 committed May 6, 2022
1 parent 3c46c6c commit 6fd3c53
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dotenv/config';
export const PORT = process.env.PORT as string || 8000;
export const MONGO_URI = process.env.MONGO_URI as string;
export const JWT_SECRET = process.env.JWT_SECRET as string;

Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import express from "express";
import App from "./services/ExpressApp"
import Database from "./services/Database";
import { PORT } from "./config";

const startServer = async () => {

Expand All @@ -10,9 +11,9 @@ const startServer = async () => {

await App(app);

app.listen(8000, () => {
app.listen(PORT, () => {

console.log("Listening on port 8000.");
console.log(`Listening on port ${PORT}.`);
});
}

Expand Down

0 comments on commit 6fd3c53

Please sign in to comment.