From e5756769134f47e0b3b9528a2921d965bfa02de6 Mon Sep 17 00:00:00 2001 From: hershit-shukla Date: Fri, 12 Jul 2024 10:31:22 +0530 Subject: [PATCH] chore: Update express server to listen on process.env.PORT or 3000 --- Backend/src/index.ts | 6 +++--- package-lock.json | 12 ++++++++++++ package.json | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Backend/src/index.ts b/Backend/src/index.ts index fe4a413..3e95458 100644 --- a/Backend/src/index.ts +++ b/Backend/src/index.ts @@ -10,6 +10,6 @@ app.use(express.json()) app.use(cookieparser()) app.use("/api/v1",rootRouter) -app.listen(3000,function() { - console.log("Listening on Port: 3000") -}) \ No newline at end of file +app.listen(process.env.PORT || 3000, function() { + console.log(`Listening on Port: ${process.env.PORT || 3000}`); +}); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ae138e3..518bb14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "argon2": "^0.40.1", "cookie-parser": "^1.4.6", "cors": "^2.8.5", + "dotenv": "^16.4.5", "express": "^4.19.2", "jsonwebtoken": "^9.0.2", "nodemailer": "^6.9.13", @@ -402,6 +403,17 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/ecdsa-sig-formatter": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", diff --git a/package.json b/package.json index 3b51ee4..33bfdc9 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "argon2": "^0.40.1", "cookie-parser": "^1.4.6", "cors": "^2.8.5", + "dotenv": "^16.4.5", "express": "^4.19.2", "jsonwebtoken": "^9.0.2", "nodemailer": "^6.9.13",