✨ update to use new Lambert-server

This commit is contained in:
Flam3rboy
2021-01-04 16:10:12 +01:00
parent 9955183fa1
commit 35655773d7
5 changed files with 3385 additions and 1584 deletions
+3 -3
View File
@@ -15,7 +15,7 @@ type Attachment = {
router.post("/:filename", multer_.single("attachment"), async (req, res) => {
const { buffer, mimetype } = req.file;
const { filename } = req.params;
const { db } = req.server;
const { db } = req.cdn;
const File: Attachment = {
filename,
@@ -30,7 +30,7 @@ router.post("/:filename", multer_.single("attachment"), async (req, res) => {
});
router.get("/:hash/:filename", async (req, res) => {
const { db } = req.server;
const { db } = req.cdn;
const { hash, filename } = req.params;
const File: Attachment = await db.data.attachments({ id: hash, filename: filename }).get();
@@ -41,7 +41,7 @@ router.get("/:hash/:filename", async (req, res) => {
router.delete("/:hash/:filename", async (req, res) => {
const { hash, filename } = req.params;
const { db } = req.server;
const { db } = req.cdn;
await db.data.attachments({ id: hash, filename: filename }).delete();
return res.send({ success: true, message: "attachment deleted" });
+2 -2
View File
@@ -30,7 +30,7 @@ const DEFAULT_FETCH_OPTIONS: any = {
router.post("/", bodyParser.json(), async (req, res) => {
if (!req.body) throw new Error("Invalid Body (url missing) \nExample: url:https://discord.com");
const { db } = req.server;
const { db } = req.cdn;
const { url } = req.body;
const ID = btoa(url);
@@ -72,7 +72,7 @@ router.post("/", bodyParser.json(), async (req, res) => {
});
router.get("/:id/:filename", async (req, res) => {
const { db } = req.server;
const { db } = req.cdn;
const { id, filename } = req.params;
const { image, type } = await db.data.externals({ id: id }).get();
const imageBuffer = Buffer.from(image, "base64");