removed old api/pages

This commit is contained in:
tmshv committed 2019-08-02 18:31:00 +03:00
1 parent 3ca52d6903
commit aed6c1aac7
1 file changed
-29
-29
View File
@@ -1,29 +0,0 @@
const { get } = require('koa-route')
const getPathWithNoTrailingSlash = require('../lib/url').getPathWithNoTrailingSlash
const Page = require('../core/Page')
function getPage() {
return get('/api/pages/*', async ctx => {
const path = getPathWithNoTrailingSlash(ctx.path)
const pagePath = path.replace('/api/pages', '')
const resource = await Page.findByUrl(pagePath)
if (!resource) {
ctx.status = 404
ctx.body = {
error: 'not found'
}
} else {
ctx.body = {
id: resource.id,
title: resource.title,
url: resource.url,
data: resource.data,
preview: resource.preview,
}
}
})
}
exports.getPage = getPage