Now follows our airbnb linting schema.

This commit is contained in:
2017-10-26 14:52:00 +02:00
parent 6dd9cf7083
commit e417fedece
5 changed files with 49 additions and 48 deletions

View File

@@ -1,10 +1,9 @@
const express = require('express');
var express= require('express'); // call express const bodyParser = require('body-parser');
var app = express(); // define our app using express
var bodyParser = require('body-parser');
const tokenToUser = require('./middleware/tokenToUser'); const tokenToUser = require('./middleware/tokenToUser');
const mustBeAuthenticated = require('./middleware/mustBeAuthenticated'); const mustBeAuthenticated = require('./middleware/mustBeAuthenticated');
const app = express(); // define our app using express
// this will let us get the data from a POST // this will let us get the data from a POST
// configure app to use bodyParser() // configure app to use bodyParser()
app.use(bodyParser.json()); app.use(bodyParser.json());
@@ -14,9 +13,9 @@ app.use(bodyParser.json());
/* Decode the Authorization header if provided */ /* Decode the Authorization header if provided */
// router.use(tokenToUser); // router.use(tokenToUser);
var port = 31459; // set our port const port = 31459; // set our port
var router = express.Router(); const router = express.Router();
var allowedOrigins = ['https://kevinmidboe.com', 'http://localhost:8080'] const allowedOrigins = ['https://kevinmidboe.com', 'http://localhost:8080'];
// router.use(bodyParser.json()); // router.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.urlencoded({ extended: true }));
@@ -25,10 +24,10 @@ app.use(bodyParser.urlencoded({ extended: true }));
/* Decode the Authorization header if provided */ /* Decode the Authorization header if provided */
router.use(tokenToUser); router.use(tokenToUser);
router.use(function(req, res, next) { router.use((req, res, next) => {
// TODO add logging of all incoming // TODO add logging of all incoming
console.log('Request: ', req.originalUrl); console.log('Request: ', req.originalUrl);
var origin = req.headers.origin; const origin = req.headers.origin;
if (allowedOrigins.indexOf(origin) > -1) { if (allowedOrigins.indexOf(origin) > -1) {
console.log('allowed'); console.log('allowed');
res.setHeader('Access-Control-Allow-Origin', origin); res.setHeader('Access-Control-Allow-Origin', origin);
@@ -39,9 +38,9 @@ router.use(function(req, res, next) {
next(); next();
}); });
router.get('/', function(req, res) { router.get('/', ((req, res) => {
res.json({ message: 'hooray! welcome to this api!' }); res.json({ message: 'hooray! welcome to this api!' });
}); }));
/** /**
* User * User

View File

@@ -1,5 +1,5 @@
const configuration = require('src/config/configuration').getInstance();
const GitRepository = require('src/git/gitRepository'); const GitRepository = require('src/git/gitRepository');
const gitRepository = new GitRepository(); const gitRepository = new GitRepository();
function dumpHookController(req, res) { function dumpHookController(req, res) {
@@ -9,7 +9,7 @@ function dumpHookController(req, res) {
}) })
.catch((error) => { .catch((error) => {
res.status(500); res.status(500);
}) });
} }
module.exports = dumpHookController; module.exports = dumpHookController;

View File

@@ -1,4 +1,5 @@
const RequestRepository = require('src/plex/requestRepository.js'); const RequestRepository = require('src/plex/requestRepository.js');
const requestRepository = new RequestRepository(); const requestRepository = new RequestRepository();
/** /**

View File

@@ -1,4 +1,5 @@
const StrayRepository = require('src/seasoned/strayRepository'); const StrayRepository = require('src/seasoned/strayRepository');
const strayRepository = new StrayRepository(); const strayRepository = new StrayRepository();
function verifyStrayController(req, res) { function verifyStrayController(req, res) {