Skip to content
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

Why is this api better than next-connect? #4

Closed
bmstefanski opened this issue Sep 22, 2021 · 2 comments
Closed

Why is this api better than next-connect? #4

bmstefanski opened this issue Sep 22, 2021 · 2 comments
Labels
question Further information is requested

Comments

@bmstefanski
Copy link

As in the title, why should I use this and not https://github.com/hoangvvo/next-connect#readme ?

@neg4n neg4n added the question Further information is requested label Sep 22, 2021
@neg4n
Copy link
Owner

neg4n commented Sep 22, 2021

Hey. I wouldn't say its better - I'd rather say it is different.

I've been using next-connect for a while but I found its API a bit unintuitive. Probably because of combining routing functionality (which i believe Next.js handles very well on its own) with middleware layer. I also had some issue most likely related to route pattern matching although I did not take advantage of that functionality in my code at all. I neither found fix nor workaround.

I took an opportunity and I've created next-api-compose which completly fit my needs.

Some next-api-compose features that I haven't seen in next-connect:

  • its designed with higher order function middleware approach (as recommended in Next.js docs section about writing middleware.) that relies on intercepting reqand res objects.
  • it has utility that helps with compatibility and also significantly reduces boilerplate code when it comes to using multiple Connect/Express middleware, by converting them to higher order functions and leveraging the original middleware.
  • it has no dependencies at all - the area of occurring for errors is small.
  • it is designed specially for Next.js - mentioned earlier area is even smaller.

... and generally I thought sharing next-api-compose with the world would be super cool 😎

@bmstefanski
Copy link
Author

Yeah, that makes perfect sense. Thanks and stay sigma :)!

@neg4n neg4n pinned this issue Sep 23, 2021
@neg4n neg4n reopened this Sep 23, 2021
Repository owner locked as resolved and limited conversation to collaborators Sep 23, 2021
@neg4n neg4n closed this as completed Sep 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants