import type { APIRoute } from 'astro'; import { v4 as uuidV4 } from 'uuid'; import type Thread from '../../models/Thread' import { api } from '../../lib/api' export async function post({ params, request }): APIRoute { const form = await request.formData(); let t: Thread = {}; t.id = uuidV4().toString(); t.ThreadName = form.get('ThreadName').toString(); // data["ThreadCreator"] = locals.userid; t.ThreadCreator = ''; t.ThreadText = form.get('ThreadText').toString(); t.Comments = []; t.CreationDate = Date.now(); // data["ImageId"] = await post_img(base64image, writeFileSync); // data["FileType"] = get_img_type(base64image); t.ImageId = form.get('image').toString(); t.FileType = ''; // await api('post', `thread/${form.get('board')}`, JSON.stringify(data)); return new Response(null, { status: 200 }); }