diff --git a/.eslintrc b/.eslintrc index 10b0b868..4a4e05f1 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,6 +9,8 @@ }}], // Spaces inside curlies, except prop={{}} "react/prefer-stateless-function": 0, // Don't prefer stateless components "no-else-return": 0, + "new-cap": 0, + "no-param-reassign": 0, }, "settings" : { "import/resolver": { diff --git a/server/api/apiKeys.js b/server/api/apiKeys.js index 1dda17fc..3570334e 100644 --- a/server/api/apiKeys.js +++ b/server/api/apiKeys.js @@ -1,8 +1,7 @@ import Router from 'koa-router'; import httpErrors from 'http-errors'; -import _ from 'lodash'; -import auth from './authentication'; +import auth from './middlewares/authentication'; import pagination from './middlewares/pagination'; import { presentApiKey } from '../presenters'; import { ApiKey } from '../models'; diff --git a/server/api/collections.js b/server/api/collections.js index 3cb9a0b9..46b5824b 100644 --- a/server/api/collections.js +++ b/server/api/collections.js @@ -2,7 +2,7 @@ import Router from 'koa-router'; import httpErrors from 'http-errors'; import _ from 'lodash'; -import auth from './authentication'; +import auth from './middlewares/authentication'; import pagination from './middlewares/pagination'; import { presentCollection } from '../presenters'; import { Atlas } from '../models'; diff --git a/server/api/documents.js b/server/api/documents.js index 5b4e15fb..a48ae409 100644 --- a/server/api/documents.js +++ b/server/api/documents.js @@ -8,7 +8,7 @@ import isUUID from 'validator/lib/isUUID'; const URL_REGEX = /^[a-zA-Z0-9-]*-([a-zA-Z0-9]{10,15})$/; -import auth from './authentication'; +import auth from './middlewares/authentication'; // import pagination from './middlewares/pagination'; import { presentDocument } from '../presenters'; import { Document, Atlas } from '../models'; diff --git a/server/api/index.js b/server/api/index.js index c5000d39..1df8e389 100644 --- a/server/api/index.js +++ b/server/api/index.js @@ -11,7 +11,7 @@ import documents from './documents'; import hooks from './hooks'; import apiKeys from './apiKeys'; -import validation from './validation'; +import validation from './middlewares/validation'; import methodOverride from '../middlewares/methodOverride'; import cache from '../middlewares/cache'; diff --git a/server/api/authentication.js b/server/api/middlewares/authentication.js similarity index 89% rename from server/api/authentication.js rename to server/api/middlewares/authentication.js index c9358b7c..d2741f8e 100644 --- a/server/api/authentication.js +++ b/server/api/middlewares/authentication.js @@ -1,7 +1,7 @@ import httpErrors from 'http-errors'; import JWT from 'jsonwebtoken'; -import { User } from '../models'; +import { User } from '../../models'; export default function auth({ require = true } = {}) { return async function authMiddleware(ctx, next) { @@ -19,7 +19,8 @@ export default function auth({ require = true } = {}) { } } else { if (require) { - throw httpErrors.Unauthorized('Bad Authorization header format. Format is "Authorization: Bearer "\n'); + throw httpErrors.Unauthorized(`Bad Authorization header format. \ + Format is "Authorization: Bearer "\n`); } } } else if (ctx.request.query.token) { diff --git a/server/api/validation.js b/server/api/middlewares/validation.js similarity index 99% rename from server/api/validation.js rename to server/api/middlewares/validation.js index 7fc7ce0e..019a8b01 100644 --- a/server/api/validation.js +++ b/server/api/middlewares/validation.js @@ -23,4 +23,4 @@ export default function validation() { return next(); }; -} \ No newline at end of file +} diff --git a/server/api/user.js b/server/api/user.js index 6451ca85..5ebbb945 100644 --- a/server/api/user.js +++ b/server/api/user.js @@ -5,7 +5,7 @@ import { makePolicy, signPolicy, } from '../utils/s3'; -import auth from './authentication'; +import auth from './middlewares/authentication'; import { presentUser } from '../presenters'; const router = new Router();