Adding dependency to load variables from .env file

pull/1/head
Jennifer Nguyen 2020-07-01 23:56:18 -07:00
parent 48ecf478f7
commit 3015eeb262
3 changed files with 10 additions and 2 deletions

5
package-lock.json generated
View File

@ -491,6 +491,11 @@
"is-obj": "^2.0.0"
}
},
"dotenv": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
},
"duplexer3": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz",

View File

@ -4,6 +4,7 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"dotenv": "^8.2.0",
"express": "^4.17.1",
"pg": "^8.2.1"
},

View File

@ -1,6 +1,8 @@
require('dotenv').config()
if (!process.env.PORT) {
console.log("Missing environment variable PORT");
process.exit(1);
console.log("Missing environment variable PORT");
process.exit(1);
}
export const port: number = parseInt(process.env.PORT as string, 10);