api pages

This commit is contained in:
tmshv committed 2019-08-01 17:40:17 +03:00
1 parent 606164bb43
commit b90b2a3e77
1 file changed
+19
+19
View File
@@ -0,0 +1,19 @@
import { connect } from '../../../src/core/db'
import Page from '../../../src/core/Page'
export default async (req, res) => {
await connect()
const items = await Page.find({})
if (items) {
res.json({
items,
})
} else {
res.status(404)
res.json({
error: `Article ${id} not found`
})
}
}