aboutsummaryrefslogtreecommitdiff
path: root/src/pages/create/thread.ts
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2022-08-28 23:22:15 +0300
committerkartofen <mladenovnasko0@gmail.com>2022-08-28 23:22:15 +0300
commit9d952483f250a97cbeab4061fa1c4e68341b330f (patch)
tree9d094911dc5178db9375eaa661e7f4bf0d5bf2cc /src/pages/create/thread.ts
parent35b06b4fc851192916e000ad5e7e2f458846448c (diff)
posting thread and image works
Diffstat (limited to 'src/pages/create/thread.ts')
-rw-r--r--src/pages/create/thread.ts32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/pages/create/thread.ts b/src/pages/create/thread.ts
index 0af3471..0a0b7d1 100644
--- a/src/pages/create/thread.ts
+++ b/src/pages/create/thread.ts
@@ -1,28 +1,16 @@
-import type { APIRoute } from 'astro';
-import { v4 as uuidV4 } from 'uuid';
+import { api } from '../../lib/api';
+import { processThreadOut } from '../../lib/thread';
-import type Thread from '../../models/Thread'
-import { api } from '../../lib/api'
+export async function post({ request }) {
+ const form = await request.formData();
-export async function post({ params, request }): APIRoute {
- const form = await request.formData();
+ console.log(form);
- 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 = '';
+ let t: Thread = await processThreadOut(form);
- // await api('post', `thread/${form.get('board')}`, JSON.stringify(data));
+ await api('post', `thread/${form.get('board')}`, JSON.stringify(t));
- return new Response(null, {
- status: 200
- });
+ return new Response(t.id, {
+ status: 200
+ });
}