mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-03 06:27:19 +01:00
move store in local storage
This commit is contained in:
@@ -2,8 +2,8 @@ import { NextApiRequest, NextApiResponse } from 'next'
|
||||
|
||||
import { brief as briefTemplate } from '../../../lib/templates'
|
||||
import renderer from '../../../lib/renderer'
|
||||
import * as store from '../../../lib/store'
|
||||
import { IDocProps } from '../../../interfaces/IDocProps'
|
||||
import { getId } from '../../../lib/id'
|
||||
|
||||
const TEMPLATES: { [key: string]: (options: IDocProps) => string } = {
|
||||
brief: briefTemplate,
|
||||
@@ -28,15 +28,11 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
return
|
||||
}
|
||||
|
||||
const id = getId(templateData)
|
||||
const texDoc = template(templateData)
|
||||
const id = await renderer(texDoc)
|
||||
const storeData = Object.assign({}, templateData, {
|
||||
id,
|
||||
created: new Date().toISOString(),
|
||||
template: templateName,
|
||||
})
|
||||
await store.add(storeData)
|
||||
res.status(200).json({ id: id })
|
||||
await renderer(id, texDoc)
|
||||
const storeData = { ...templateData, id, created: new Date().toISOString(), template: templateName }
|
||||
res.status(200).json({ id: id, data: storeData })
|
||||
} catch (err) {
|
||||
console.error('Error:', err, 'for', req.url)
|
||||
res.status(500).json({ error: err.toString() })
|
||||
|
||||
Reference in New Issue
Block a user