Skip to content

Commit

Permalink
Removed dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinWilloughby committed Apr 17, 2023
1 parent 9c7e59a commit 966ea0b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 56 deletions.
79 changes: 34 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,5 @@
"eslint": "^8.28.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.26.0"
},
"dependencies": {
"dotenv": "^16.0.3"
}
}
17 changes: 9 additions & 8 deletions server/app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
require('dotenv').config();
const http = require('http');
const mathUtils = require('./utils/math.js'); // grab utils for simple math functions
const mathUtils = require('./utils/math.js');

const port = 3000;
const port = process.env.PORT || process.env.NODE_PORT || 3000;

const onRequest = (req, res) => {
let num = mathUtils.add(10, 15); // should get capped to 20
Expand All @@ -15,12 +14,14 @@ const onRequest = (req, res) => {
res.end();
};

const app = http.createServer(onRequest).listen(port);
const app = http.createServer(onRequest).listen(port, () => {
console.log(`Server started on port ${port}`);
});

console.log(`Server started on port ${port}`);

// Check if test environment, if so export server app as a global variable for testing
/* Check if test environment, if so export server app so that
we can test it in app.test.js. Jest will automatically set
process.env.NODE_ENV to 'test' when it's running.
*/
if (process.env.NODE_ENV === 'test') {
console.log('setting env to test');
module.exports = app;
}

0 comments on commit 966ea0b

Please sign in to comment.