mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-03 14:37:21 +01:00
22 lines
573 B
TypeScript
22 lines
573 B
TypeScript
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
|