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