Open hiyaryan opened 3 weeks ago
We might also want to consider having more elaborate typing for errors going forward, instead of having ExpressError as the catch-all. It increases complexity, but also lets you handle them more precisely. We also should take a look at the JS logging libraries out there and try integrating them rather than settling on console.log.
Note that the new services
layer is printing errors to the console with console.error
. This makes the output in the console very verbose.
Instead of logging the error to the console, the error should be logged in a file and timestamped. The morgan
error should also be timestamped. Then whenever a server side error code ≥ 500 occurs, for example, the morgan
error can be traced to the error in the log.
Note that morgan
middleware does not have to be used if another logger is preferred for HTTP request/response logging.
TODO added to line 116 of
requestBetaAccess
function in middelware/access.tsTODO: Add server-side logging for errors; Expand ExpressError to include a
log
method to log errors from catch blocks to a file.eslint-disable-next-line @typescript-eslint/no-unused-vars
ESLint disable comment used to allowerr
caught in catch block to not be used. The catch block simply passes anExpressError
to the error handler without using the runtime error stored inerr
.This suggests that ExpressError can be expanded to include a logging feature as described in the TODO.