summary refs log tree commit diff
path: root/src/routes/attachments.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/attachments.ts')
-rw-r--r--src/routes/attachments.ts13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/routes/attachments.ts b/src/routes/attachments.ts
index 9f016174..87368e48 100644
--- a/src/routes/attachments.ts
+++ b/src/routes/attachments.ts
@@ -1,6 +1,7 @@
 import { Router } from "express";
 import multer from "multer";
-import Snowflake from "../Snowflake";
+import { Snowflake } from "@fosscord/server-util";
+import { storage } from "../util/Storage";
 
 const multer_ = multer();
 const router = Router();
@@ -11,11 +12,11 @@ type Attachment = {
 	id: string;
 	type: string;
 };
-
 router.post("/:filename", multer_.single("attachment"), async (req, res) => {
 	const { buffer, mimetype } = req.file;
 	const { filename } = req.params;
-	const { db } = req.cdn;
+
+	// storage.set(filename, );
 
 	const File: Attachment = {
 		filename,
@@ -23,14 +24,9 @@ router.post("/:filename", multer_.single("attachment"), async (req, res) => {
 		id: Snowflake.generate(),
 		type: mimetype,
 	};
-
-	if (!(await db.data.attachments.push(File))) throw new Error("Error uploading file");
-
-	return res.status(201).send({ success: true, message: "attachment uploaded", id: File.id, filename });
 });
 
 router.get("/:hash/:filename", async (req, res) => {
-	const { db } = req.cdn;
 	const { hash, filename } = req.params;
 
 	const File: Attachment = await db.data.attachments({ id: hash, filename: filename }).get();
@@ -41,7 +37,6 @@ router.get("/:hash/:filename", async (req, res) => {
 
 router.delete("/:hash/:filename", async (req, res) => {
 	const { hash, filename } = req.params;
-	const { db } = req.cdn;
 
 	await db.data.attachments({ id: hash, filename: filename }).delete();
 	return res.send({ success: true, message: "attachment deleted" });