As I was working on creating the properties of a Request object without using global declarations, I encountered a problem that threw me off course.
I attempted to utilize the generic Locals for Request in order to set up the req.auth property, but unfortunately, it resulted in an error. This has left me questioning the necessity of this generic. Here's a snippet of what I tried:
import { Request, Response, NextFunction } from "express";
interface Local {
auth: {
token: string;
payload: Object;
}
}
const example = function (req: Request<{}, {}, {}, {}, Local>, res: Response, next: NextFunction) {
req.auth
next();
};