-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for configuring the default handlers [SDK-3566] #840
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Nice 👏 Can you update the examples, I'm thinking these ones:
|
export type Handlers = ApiHandlers | ErrorHandlers; | ||
|
||
type ApiHandlers = { | ||
[key: string]: NextApiHandler; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added types to this in b02f9b4
Also noticed that the login
, logout
etc types weren't HandleLogin
, HandleLogout
but NextApiHandler
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 👍 just the examples updates
📋 Changes
Previously it was not possible to configure the default handlers. For example, to pass a
connection
parameter to the login handler, it had to be overridden.This PR allows to configure default handlers by passing an options object to them. This is the same options object that can be passed when overriding a handler.
Alternatively, it is possible to pass a function that receives the request and returns an options object.
This PR also adds the ability to create new handlers by configuring the default ones, which is useful e.g. for easily creating a signup handler.
📎 References
Fixes #379, #381, #400, #471, #701
🎯 Testing
Besides adding unit tests, the changes were tested manually using the kitchen sink example app.