cosette/server/api/cosette.post.js

16 lines
502 B
JavaScript
Raw Normal View History

2022-08-11 09:57:51 +02:00
import { add } from '../controller'
import { useBody, callHandler } from 'h3'
import { uploadService } from '../services/upload-service'
export default defineEventHandler(async (event) => {
try {
const handler = uploadService().generateHandler()
await callHandler(handler, event.req, event.res)
const body = await useBody(event)
body.imgs = [event.req.file?.filename?]
add(body)
return { success: true }
} catch (e) {
return { success: false, reason: e.message }
}
})