I'm using express for routing and I don't need to use the Request object in my controller method. However, I can't find a simple way to force the exclusion of the Request parameter.
This first example passes typescript validation.
public async findAll(req: Request, res: Response) {
// search the db for all transactions
const transactions = await Transaction.find();
res.status(200).send({ transactions, incoming: req.body });
}
This example compiles into valid javascript but doesn't pass typescript validation as I get the error 'req' is declared but its value is never read.
public async findAll(req: Request, res: Response) {
// search the db for all transactions
const transactions = await Transaction.find();
res.status(200).send({ transactions });
}
Ideally I don't want to include the Request in my method parameter at all. Is this possible without an intricate workaround?