app moved to next.js
This commit is contained in:
1 parent
dcca513aea
commit
43af2996bf
48 files changed
+1147
-1027
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { dbUri } from '../../src/config'
|
||||
import { connect } from '../../src/core/db'
|
||||
import Page from '../../src/core/Page'
|
||||
import { getPathWithNoTrailingSlash } from '../../src/lib/url'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const page = getPathWithNoTrailingSlash(req.query.page)
|
||||
const resource = await Page.findByUrl(page)
|
||||
|
||||
if (resource) {
|
||||
res.json({
|
||||
id: resource.id,
|
||||
title: resource.title,
|
||||
url: resource.url,
|
||||
data: resource.data,
|
||||
preview: resource.preview,
|
||||
})
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Image ${page} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user