Linted app and server.js files.

This commit is contained in:
2018-02-07 13:52:39 +01:00
parent 58449fc753
commit 93e1ef6d99
2 changed files with 21 additions and 19 deletions

View File

@@ -5,10 +5,9 @@ const tokenToUser = require('./middleware/tokenToUser');
const mustBeAuthenticated = require('./middleware/mustBeAuthenticated');
const configuration = require('src/config/configuration').getInstance();
// TODO: Have our raven router check if there is a value, if not don't enable raven.
// 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
@@ -34,27 +33,27 @@ 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);
const origin = req.headers.origin;
if (allowedOrigins.indexOf(origin) > -1) {
console.log('allowed');
res.setHeader('Access-Control-Allow-Origin', origin);
}
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, loggedinuser');
res.header('Access-Control-Allow-Methods', 'POST, GET, PUT');
// TODO add logging of all incoming
console.log('Request: ', req.originalUrl);
const origin = req.headers.origin;
if (allowedOrigins.indexOf(origin) > -1) {
console.log('allowed');
res.setHeader('Access-Control-Allow-Origin', origin);
}
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, loggedinuser');
res.header('Access-Control-Allow-Methods', 'POST, GET, PUT');
next();
next();
});
router.get('/', function mainHandler(req, res) {
throw new Error('Broke!');
throw new Error('Broke!');
});
app.use(Raven.errorHandler());
app.use(function onError(err, req, res, next) {
res.statusCode = 500;
res.end(res.sentry + '\n');
res.statusCode = 500;
res.end(res.sentry + '\n');
});
/**

View File

@@ -2,7 +2,10 @@ const config = require('src/config/configuration').getInstance();
const app = require('./app');
module.exports = app.listen(config.get('webserver', 'port'), () => {
console.log('seasonedAPI');
console.log(`Database is located at ${config.get('database', 'host')}`);
console.log(`Webserver is listening on ${config.get('webserver', 'port')}`);
})
/* eslint-disable no-console */
console.log('seasonedAPI');
/* eslint-disable no-console */
console.log(`Database is located at ${config.get('database', 'host')}`);
/* eslint-disable no-console */
console.log(`Webserver is listening on ${config.get('webserver', 'port')}`);
});