route pages eslinted
This commit is contained in:
1 parent
bbf1819d9d
commit
fc9faaaf22
1 file changed
+9
-9
+9
-9
@@ -1,14 +1,14 @@
|
||||
import route from 'koa-route';
|
||||
import {c} from '../core/db';
|
||||
import {accepts, index} from './';
|
||||
import route from 'koa-route'
|
||||
import {c} from '../core/db'
|
||||
import {accepts, index} from './'
|
||||
|
||||
async function exists(ctx) {
|
||||
const page = await getPage(ctx.path);
|
||||
return Boolean(page);
|
||||
const page = await getPage(ctx.path)
|
||||
return Boolean(page)
|
||||
}
|
||||
|
||||
async function getPage(path) {
|
||||
return await c('pages').findOne({url: path});
|
||||
return await c('pages').findOne({url: path})
|
||||
}
|
||||
|
||||
export default function () {
|
||||
@@ -16,9 +16,9 @@ export default function () {
|
||||
'text/html': index(exists),
|
||||
'text/plain': index(exists),
|
||||
'application/json': async(ctx) => {
|
||||
const page = await getPage(ctx.path);
|
||||
if (!page) ctx.status = 404;
|
||||
else ctx.body = page;
|
||||
const page = await getPage(ctx.path)
|
||||
if (!page) ctx.status = 404
|
||||
else ctx.body = page
|
||||
}
|
||||
}))
|
||||
};
|
||||
Reference in new issue
Block a user