aboutsummaryrefslogtreecommitdiff
path: root/src/pages/create/thread.ts
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2022-08-28 00:08:07 +0300
committerkartofen <mladenovnasko0@gmail.com>2022-08-28 00:08:07 +0300
commit35b06b4fc851192916e000ad5e7e2f458846448c (patch)
treef9a1536aae76a5058d26f8b82ddcf63e83f500cc /src/pages/create/thread.ts
parent8f5278eb443864910dd9c2131c992d71e3af2d20 (diff)
working on thread uploading
Diffstat (limited to 'src/pages/create/thread.ts')
-rw-r--r--src/pages/create/thread.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/pages/create/thread.ts b/src/pages/create/thread.ts
new file mode 100644
index 0000000..0af3471
--- /dev/null
+++ b/src/pages/create/thread.ts
@@ -0,0 +1,28 @@
+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
+ });
+}