import { add } from '../controller' import { readBody, callHandler, sendRedirect } 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 readBody(event) body.images = event.req.files.map(f => f.filename) add(body) return sendRedirect(event, '/') } catch (e) { return { success: false, reason: e.message } } })