From 35b06b4fc851192916e000ad5e7e2f458846448c Mon Sep 17 00:00:00 2001 From: kartofen Date: Sun, 28 Aug 2022 00:08:07 +0300 Subject: working on thread uploading --- src/pages/create/[board].astro | 54 ++++++++++++++++++++++++++++++++++++++++++ src/pages/create/thread.ts | 28 ++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/pages/create/[board].astro create mode 100644 src/pages/create/thread.ts (limited to 'src/pages/create') diff --git a/src/pages/create/[board].astro b/src/pages/create/[board].astro new file mode 100644 index 0000000..45f8b0d --- /dev/null +++ b/src/pages/create/[board].astro @@ -0,0 +1,54 @@ +--- +import Default from '../../layouts/Default.astro' +const { board } = Astro.params; +--- + +

{board}

+ + +
+
+ +
+ + +
+ +
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 + }); +} -- cgit v1.2.3