Skip to content

Commit

Permalink
Task2: 2D - Secrets File
Browse files Browse the repository at this point in the history
  • Loading branch information
rjgeng committed Feb 23, 2022
1 parent 86fc7d9 commit 43bdcc4
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PORT=9000
NODE_ENV=development
BCRYPT_ROUNDS=8
SECRET='make it long, random, and very secret'
JWT_SECRET='make it long, random, and very secret'
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ web_modules/
.yarn-integrity

# dotenv environment variables file
.env

.env.test

# parcel-bundler cache (https://parceljs.org/)
Expand Down Expand Up @@ -119,7 +119,7 @@ dist
.DS_Store

# VSCode settings
.vscode/


# testing db
testing.db3
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/index.js"
},
{
"type": "node",
"request": "launch",
"name": "nodemon",
"runtimeExecutable": "nodemon",
"program": "${workspaceFolder}/index.js",
"restart": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"env": {
"debug": "app:*"
}
}
]
}
9 changes: 7 additions & 2 deletions api/secrets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
If no fallback is provided, TESTS WON'T WORK and other
developers cloning this repo won't be able to run the project as is.
*/
module.exports = {
require('dotenv').config()

}
module.exports = {
PORT: process.env.PORT || 9000,
NODE_ENV: process.env.NODE_ENV || 'development',
BCRYPT_ROUNDS: process.env.BCRYPT_ROUNDS || 8,
JWT_SECRET: process.env.JWT_SECRET || 'keep it secret!!!!!'
}
9 changes: 4 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const server = require('./api/server.js');

const PORT = process.env.PORT || 9000;
const server = require('./api/server')
const { PORT } = require('./api/secrets')

server.listen(PORT, () => {
console.log(`Listening on port ${PORT}...`);
});
console.log(`\n** Running on port ${PORT} **\n`)
})
14 changes: 14 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dependencies": {
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^16.0.0",
"express": "^4.17.1",
"helmet": "^4.6.0",
"knex": "^0.95.14",
Expand Down

0 comments on commit 43bdcc4

Please sign in to comment.