From 491565aef88ce08444bba83a571c1a5006271f56 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Mon, 31 May 2021 21:03:09 +0200 Subject: :zap: add explicit types to req and res --- src/Server.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/Server.ts') diff --git a/src/Server.ts b/src/Server.ts index 50110bec..5ae65918 100644 --- a/src/Server.ts +++ b/src/Server.ts @@ -9,8 +9,8 @@ import i18nextMiddleware, { I18next } from "i18next-http-middleware"; import i18nextBackend from "i18next-node-fs-backend"; import { ErrorHandler } from "./middlewares/ErrorHandler"; import { BodyParser } from "./middlewares/BodyParser"; -import express, { Router } from "express"; -import fetch, { Response } from "node-fetch"; +import express, { Router, Request, Response } from "express"; +import fetch, { Response as FetchResponse } from "node-fetch"; import mongoose from "mongoose"; import path from "path"; @@ -31,13 +31,13 @@ declare global { const assetCache = new Map< string, { - response: Response; + response: FetchResponse; buffer: Buffer; } >(); export class FosscordServer extends Server { - public options: FosscordServerOptions; + public declare options: FosscordServerOptions; constructor(opts?: Partial) { // @ts-ignore @@ -101,9 +101,9 @@ export class FosscordServer extends Server { this.app.use("/assets", express.static(path.join(__dirname, "..", "assets"))); - this.app.get("/assets/:file", async (req, res) => { + this.app.get("/assets/:file", async (req: Request, res: Response) => { delete req.headers.host; - var response: Response; + var response: FetchResponse; var buffer: Buffer; const cache = assetCache.get(req.params.file); if (!cache) { @@ -140,7 +140,7 @@ export class FosscordServer extends Server { return res.send(buffer); }); - this.app.get("*", (req, res) => { + this.app.get("*", (req: Request, res: Response) => { res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24); res.set("content-type", "text/html"); res.send( -- cgit 1.5.1