hoangvvo / next-connect

The TypeScript-ready, minimal router and middleware layer for Next.js, Micro, Vercel, or Node.js http/http2
https://www.npmjs.com/package/next-connect
MIT License
1.62k stars 65 forks source link

In what cases does it make sense to have a factory function for the handler vs using different handler instances? #214

Open gascenciom1998 opened 1 year ago

gascenciom1998 commented 1 year ago

Currently, we instantiate a new handler on all of our endpoints, but I see that we can also have a factory function for a handler and call it on each endpoint. When does it make sense to do one or the other?