Unsafe use of res.end()

Calling res.end() does not terminate middleware's execution. Explicit exit from the function is necessary to prevent unwanted side-effects, which can include a "Error: Can't set headers after they are sent." from another (later) middleware.