Thanks! Indeed, my workaround here is to define a function that returns a new instance of a base handler:
export const baseHandler = () => nc({ // 404 error handler onNoMatch: (req, res) => res.status(404).send({ message: `API route not found: ${req.url}`, }), // 500 error handler onError: (err, req, res) => res.status(500).send({ message: `Unexpected error.`, error: err.toString(), }), }); export const secureHandler = baseHandler() .use(apiLimiter) .use(bearerAuth) .use(acl);
Article updated :).
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks! Indeed, my workaround here is to define a function that returns a new instance of a base handler:
Article updated :).