summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-31 21:01:28 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-31 21:01:28 +0200
commite4fc61dc347cc54d81eded31000377ee9e78e888 (patch)
treeb25e31840197801cfb601292001a7b119ff0d9a5
parent:sparkles: start.ts file (diff)
downloadserver-e4fc61dc347cc54d81eded31000377ee9e78e888.tar.xz
:zap: add explicit types to req and res
-rw-r--r--src/routes/attachments.ts8
-rw-r--r--src/routes/avatars.ts8
-rw-r--r--src/routes/external.ts6
3 files changed, 11 insertions, 11 deletions
diff --git a/src/routes/attachments.ts b/src/routes/attachments.ts
index e99b8d87..2e635b43 100644
--- a/src/routes/attachments.ts
+++ b/src/routes/attachments.ts
@@ -1,4 +1,4 @@
-import { Router } from "express";
+import { Router, Response, Request } from "express";
 import { Config, Snowflake } from "@fosscord/server-util";
 import { storage } from "../util/Storage";
 import FileType from "file-type";
@@ -8,7 +8,7 @@ import imageSize from "image-size";
 
 const router = Router();
 
-router.post("/:channel_id", multer.single("file"), async (req, res) => {
+router.post("/:channel_id", multer.single("file"), async (req: Request, res: Response) => {
 	if (req.headers.signature !== Config.get().security.requestSignature)
 		throw new HTTPError("Invalid request signature");
 
@@ -44,7 +44,7 @@ router.post("/:channel_id", multer.single("file"), async (req, res) => {
 	return res.json(file);
 });
 
-router.get("/:channel_id/:id/:filename", async (req, res) => {
+router.get("/:channel_id/:id/:filename", async (req: Request, res: Response) => {
 	const { channel_id, id, filename } = req.params;
 
 	const file = await storage.get(`attachments/${channel_id}/${id}/${filename}`);
@@ -56,7 +56,7 @@ router.get("/:channel_id/:id/:filename", async (req, res) => {
 	return res.send(file);
 });
 
-router.delete("/:channel_id/:id/:filename", async (req, res) => {
+router.delete("/:channel_id/:id/:filename", async (req: Request, res: Response) => {
 	if (req.headers.signature !== Config.get().security.requestSignature)
 		throw new HTTPError("Invalid request signature");
 
diff --git a/src/routes/avatars.ts b/src/routes/avatars.ts
index 973c45fc..321ae02e 100644
--- a/src/routes/avatars.ts
+++ b/src/routes/avatars.ts
@@ -1,4 +1,4 @@
-import { Router } from "express";
+import { Router, Response, Request } from "express";
 import { Config, Snowflake } from "@fosscord/server-util";
 import { storage } from "../util/Storage";
 import FileType from "file-type";
@@ -18,7 +18,7 @@ const ALLOWED_MIME_TYPES = [...ANIMATED_MIME_TYPES, ...STATIC_MIME_TYPES];
 
 const router = Router();
 
-router.post("/:user_id", multer.single("file"), async (req, res) => {
+router.post("/:user_id", multer.single("file"), async (req: Request, res: Response) => {
 	if (req.headers.signature !== Config.get().security.requestSignature)
 		throw new HTTPError("Invalid request signature");
 	if (!req.file) throw new HTTPError("Missing file");
@@ -42,7 +42,7 @@ router.post("/:user_id", multer.single("file"), async (req, res) => {
 	});
 });
 
-router.get("/:user_id/:id", async (req, res) => {
+router.get("/:user_id/:id", async (req: Request, res: Response) => {
 	var { user_id, id } = req.params;
 	id = id.split(".")[0];
 	const path = `avatars/${user_id}/${id}`;
@@ -56,7 +56,7 @@ router.get("/:user_id/:id", async (req, res) => {
 	return res.send(file);
 });
 
-router.delete("/:user_id/:id", async (req, res) => {
+router.delete("/:user_id/:id", async (req: Request, res: Response) => {
 	if (req.headers.signature !== Config.get().security.requestSignature)
 		throw new HTTPError("Invalid request signature");
 	const { user_id, id } = req.params;
diff --git a/src/routes/external.ts b/src/routes/external.ts
index dcf56c8c..3abe9c22 100644
--- a/src/routes/external.ts
+++ b/src/routes/external.ts
@@ -1,6 +1,6 @@
 // @ts-nocheck
 import bodyParser from "body-parser";
-import { Router } from "express";
+import { Router, Response, Request } from "express";
 import fetch from "node-fetch";
 import crypto from "crypto";
 import { HTTPError } from "lambert-server";
@@ -29,7 +29,7 @@ const DEFAULT_FETCH_OPTIONS: any = {
 	method: "GET",
 };
 
-router.post("/", bodyParser.json(), async (req, res) => {
+router.post("/", bodyParser.json(), async (req: Request, res: Response) => {
 	if (req.headers.signature !== Config.get().security.requestSignature)
 		throw new HTTPError("Invalid request signature");
 	if (!req.body) throw new HTTPError("Invalid Body");
@@ -50,7 +50,7 @@ router.post("/", bodyParser.json(), async (req, res) => {
 	}
 });
 
-router.get("/:id/", async (req, res) => {
+router.get("/:id/", async (req: Request, res: Response) => {
 	const { id } = req.params;
 
 	const file = await storage.get(`/external/${id}`);