⚡ add explicit types to req and res
This commit is contained in:
		
							parent
							
								
									f0d59bb37d
								
							
						
					
					
						commit
						e4fc61dc34
					
				| @ -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"); | ||||
| 
 | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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}`); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Flam3rboy
						Flam3rboy