server side cleanup
This commit is contained in:
@ -9,6 +9,8 @@
|
|||||||
}}], // Spaces inside curlies, except prop={{}}
|
}}], // Spaces inside curlies, except prop={{}}
|
||||||
"react/prefer-stateless-function": 0, // Don't prefer stateless components
|
"react/prefer-stateless-function": 0, // Don't prefer stateless components
|
||||||
"no-else-return": 0,
|
"no-else-return": 0,
|
||||||
|
"new-cap": 0,
|
||||||
|
"no-param-reassign": 0,
|
||||||
},
|
},
|
||||||
"settings" : {
|
"settings" : {
|
||||||
"import/resolver": {
|
"import/resolver": {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import Router from 'koa-router';
|
import Router from 'koa-router';
|
||||||
import httpErrors from 'http-errors';
|
import httpErrors from 'http-errors';
|
||||||
import _ from 'lodash';
|
|
||||||
|
|
||||||
import auth from './authentication';
|
import auth from './middlewares/authentication';
|
||||||
import pagination from './middlewares/pagination';
|
import pagination from './middlewares/pagination';
|
||||||
import { presentApiKey } from '../presenters';
|
import { presentApiKey } from '../presenters';
|
||||||
import { ApiKey } from '../models';
|
import { ApiKey } from '../models';
|
||||||
|
@ -2,7 +2,7 @@ import Router from 'koa-router';
|
|||||||
import httpErrors from 'http-errors';
|
import httpErrors from 'http-errors';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
import auth from './authentication';
|
import auth from './middlewares/authentication';
|
||||||
import pagination from './middlewares/pagination';
|
import pagination from './middlewares/pagination';
|
||||||
import { presentCollection } from '../presenters';
|
import { presentCollection } from '../presenters';
|
||||||
import { Atlas } from '../models';
|
import { Atlas } from '../models';
|
||||||
|
@ -8,7 +8,7 @@ import isUUID from 'validator/lib/isUUID';
|
|||||||
|
|
||||||
const URL_REGEX = /^[a-zA-Z0-9-]*-([a-zA-Z0-9]{10,15})$/;
|
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 pagination from './middlewares/pagination';
|
||||||
import { presentDocument } from '../presenters';
|
import { presentDocument } from '../presenters';
|
||||||
import { Document, Atlas } from '../models';
|
import { Document, Atlas } from '../models';
|
||||||
|
@ -11,7 +11,7 @@ import documents from './documents';
|
|||||||
import hooks from './hooks';
|
import hooks from './hooks';
|
||||||
import apiKeys from './apiKeys';
|
import apiKeys from './apiKeys';
|
||||||
|
|
||||||
import validation from './validation';
|
import validation from './middlewares/validation';
|
||||||
import methodOverride from '../middlewares/methodOverride';
|
import methodOverride from '../middlewares/methodOverride';
|
||||||
import cache from '../middlewares/cache';
|
import cache from '../middlewares/cache';
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import httpErrors from 'http-errors';
|
import httpErrors from 'http-errors';
|
||||||
import JWT from 'jsonwebtoken';
|
import JWT from 'jsonwebtoken';
|
||||||
|
|
||||||
import { User } from '../models';
|
import { User } from '../../models';
|
||||||
|
|
||||||
export default function auth({ require = true } = {}) {
|
export default function auth({ require = true } = {}) {
|
||||||
return async function authMiddleware(ctx, next) {
|
return async function authMiddleware(ctx, next) {
|
||||||
@ -19,7 +19,8 @@ export default function auth({ require = true } = {}) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (require) {
|
if (require) {
|
||||||
throw httpErrors.Unauthorized('Bad Authorization header format. Format is "Authorization: Bearer <token>"\n');
|
throw httpErrors.Unauthorized(`Bad Authorization header format. \
|
||||||
|
Format is "Authorization: Bearer <token>"\n`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ctx.request.query.token) {
|
} else if (ctx.request.query.token) {
|
@ -5,7 +5,7 @@ import {
|
|||||||
makePolicy,
|
makePolicy,
|
||||||
signPolicy,
|
signPolicy,
|
||||||
} from '../utils/s3';
|
} from '../utils/s3';
|
||||||
import auth from './authentication';
|
import auth from './middlewares/authentication';
|
||||||
import { presentUser } from '../presenters';
|
import { presentUser } from '../presenters';
|
||||||
|
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
Reference in New Issue
Block a user