Cleanup
This commit is contained in:
@ -48,7 +48,7 @@ export default function auth({ require = true } = {}) {
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
throw httpErrors.Unauthorized('Invalid api key');
|
||||
throw httpErrors.Unauthorized('Invalid API key');
|
||||
}
|
||||
|
||||
if (!apiKey) throw httpErrors.Unauthorized('Invalid token');
|
||||
|
@ -1,19 +1,17 @@
|
||||
import httpErrors from 'http-errors';
|
||||
var querystring = require('querystring');
|
||||
import querystring from 'querystring';
|
||||
|
||||
export default function pagination(options) {
|
||||
return async function paginationMiddleware(ctx, next) {
|
||||
const opts = {
|
||||
...{
|
||||
defaultLimit: 15,
|
||||
maxLimit: 100,
|
||||
},
|
||||
...options,
|
||||
};
|
||||
|
||||
let query = ctx.request.query;
|
||||
let limit = parseInt(query.limit);
|
||||
let offset = parseInt(query.offset);
|
||||
let limit = parseInt(query.limit, 10);
|
||||
let offset = parseInt(query.offset, 10);
|
||||
limit = isNaN(limit) ? opts.defaultLimit : limit;
|
||||
offset = isNaN(offset) ? 0 : offset;
|
||||
|
||||
@ -30,8 +28,7 @@ export default function pagination(options) {
|
||||
|
||||
query.limit = ctx.state.pagination.limit;
|
||||
query.offset = ctx.state.pagination.offset + query.limit;
|
||||
ctx.state.pagination.nextPath =
|
||||
'/api' + ctx.request.path + '?' + querystring.stringify(query);
|
||||
ctx.state.pagination.nextPath = `/api${ctx.request.path}?${querystring.stringify(query)}`;
|
||||
|
||||
return next();
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
export default function subdomainRedirect(options) {
|
||||
return async function subdomainRedirectMiddleware(ctx, next) {
|
||||
if (ctx.headers.host === 'beautifulatlas.com') {
|
||||
ctx.redirect('https://www.' + ctx.headers.host + ctx.path);
|
||||
ctx.redirect(`https://www.${ctx.headers.host}${ctx.path}`);
|
||||
} else {
|
||||
return next();
|
||||
}
|
||||
|
@ -32,15 +32,5 @@
|
||||
<div class="header"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
// if ('serviceWorker' in navigator) {
|
||||
// navigator.serviceWorker.register('/service-worker.js')
|
||||
// .then(function(reg) {
|
||||
// console.log('SW registration succeeded');
|
||||
// }).catch(function(error) {
|
||||
// console.log('SW registration failed: ' + error);
|
||||
// });
|
||||
// };
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user