nest-morgan
nest-morgan copied to clipboard
Using interceptor for logging is not a good idea. Middlewares FTW
Request lifecycle in Nest 6.x puts interceptors after guards. That means if some AuthGuard denies request, it won't be logged. Nest middlewares are the very first thing to execute and, conveniently, happen to be express-compatible (even when fastify adapter is used). That makes putting vanilla morgan in app.use()
before app.listen()
in main.ts the only way to correctly log all requests.