From 2fc9674548df080afbc881ef9ff2d3227334f7be Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 4 Nov 2017 18:11:44 +0100 Subject: [PATCH 1/4] Added some todos for routers/middleware and setup so that raven will be used for error handling and gets value from config file. --- seasoned_api/src/webserver/app.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/seasoned_api/src/webserver/app.js b/seasoned_api/src/webserver/app.js index 58d7498..6b4d888 100644 --- a/seasoned_api/src/webserver/app.js +++ b/seasoned_api/src/webserver/app.js @@ -3,8 +3,10 @@ const Raven = require('raven'); const bodyParser = require('body-parser'); const tokenToUser = require('./middleware/tokenToUser'); const mustBeAuthenticated = require('./middleware/mustBeAuthenticated'); +const configuration = require('src/config/configuration').getInstance(); -Raven.config('__DSN__').install(); +// TODO: Have our raven router check if there is a value, if not don't enable raven. +Raven.config(configuration.get('raven', 'DSN')).install(); const app = express(); // define our app using express app.use(Raven.requestHandler()); // this will let us get the data from a POST @@ -20,13 +22,16 @@ const port = 31459; // set our port const router = express.Router(); const allowedOrigins = ['https://kevinmidboe.com', 'http://localhost:8080']; +// TODO: All JSON handling in a single router // router.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); +// This is probably a correct middleware/router setup /* Decode the Authorization header if provided */ router.use(tokenToUser); +// TODO: Should have a separate middleware/router for handling headers. router.use((req, res, next) => { // TODO add logging of all incoming console.log('Request: ', req.originalUrl); From 6e9d511b5c9798ef847e1ea1b9136bbd11eaee93 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 4 Nov 2017 19:28:34 +0100 Subject: [PATCH 2/4] Added empty log file and stripped config file. --- seasoned_api/conf/development.json | 24 ++++++++++++++++++++++++ seasoned_api/conf/output.log | 1 + 2 files changed, 25 insertions(+) create mode 100644 seasoned_api/conf/development.json create mode 100644 seasoned_api/conf/output.log diff --git a/seasoned_api/conf/development.json b/seasoned_api/conf/development.json new file mode 100644 index 0000000..e349515 --- /dev/null +++ b/seasoned_api/conf/development.json @@ -0,0 +1,24 @@ +{ + "database": { + "host": "../shows.db" + }, + "webserver": { + "port": 31459 + }, + "tmdb": { + "apiKey": "" + }, + "raven": { + "DSN": "" + }, + "mail": { + "host": "", + "user": "", + "password": "", + "user_pi": "", + "password_pi": "" + }, + "authentication": { + "secret": "" + } +} diff --git a/seasoned_api/conf/output.log b/seasoned_api/conf/output.log new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/seasoned_api/conf/output.log @@ -0,0 +1 @@ + From dc685ebcdd0046225a4e6767188d9f1a4e20e031 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 4 Nov 2017 19:30:57 +0100 Subject: [PATCH 3/4] Removed conf files from api. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2a9441f..8499e28 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,6 @@ webpage/js/env_variables.js client/dist src/webserver/access.log seasoned_api/conf/development.json +seasoned_api/conf/output.log yarn-error.log */yarn.lock From 0e4f96640cd01f6f09d23de362483ce658eec6b8 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 4 Nov 2017 19:34:28 +0100 Subject: [PATCH 4/4] Ommited to entire conf folder in api. --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8499e28..fecc907 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ npm-debug.log webpage/js/env_variables.js client/dist src/webserver/access.log -seasoned_api/conf/development.json -seasoned_api/conf/output.log +./seasoned_api/conf/ yarn-error.log */yarn.lock