Adding Nest.js' data passing pattern to decorators #361
sannajammeh
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
You can have it as: export const Auth = (role: string) => createMiddlewareDecorator(
async (req: NextApiRequest, _: NextApiResponse, next: NextFunction, data: string) => {
// Auth logic ...
// Make use of the `role`
next();
}
); Does it serve your needs? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently this functionality taken from Nest.js docs isn't possible as far as I know.
I am unable unsure about how one would make this possible is next-api-decorators.
Perhaps adding a data argument behind the NextFunction is the way to go.
Or having a custom
applyDecorators
function like Nest.js would also make this process delightful.Beta Was this translation helpful? Give feedback.
All reactions