mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-03 06:27:19 +01:00
change api
This commit is contained in:
21
pages/api/document/latest.ts
Normal file
21
pages/api/document/latest.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
|
||||
import { list as storeList } from '../../../lib/store'
|
||||
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
if (req.method !== 'GET') {
|
||||
res.status(405).json({ statusCode: 405, message: 'Method Not Allowed' })
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const latest = await storeList();
|
||||
res.status(200).json(latest);
|
||||
} catch (err) {
|
||||
console.error('Error:', err, 'for', req.url);
|
||||
res.status(500).json({ error: err.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
export default handler
|
||||
Reference in New Issue
Block a user