cosette/server/api/cosette.post.js
2022-08-11 09:57:51 +02:00

16 lines
No EOL
502 B
JavaScript

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 }
}
})