#Api
1 messages · Page 1 of 1 (latest)
next api routes is designed to be run in serverless environment. In dedicated backend, you can do much more things like scheduleing, cron jobs, realtime with websocket, and more powerful middlewares
in next.js, its possible to do all that but just harder since its not meant to acoomodate those features
Its already abstracted for simple Request and Response use case, with the addition of Streaming
you can host nextjs on a server for long lived connections so in that case isnt all of those possible?
i never said its not possible
It wasn't made for it
It's like Sure you can make a massive website with a backend in vanilla js.. but you dont
Cause it wasn't made to do that task
Same way the next api routes were made for small scales
Quick db hirs
Hirs
Hits
That's why it's so easy to hist
Host
and how is express any more capable than nextjs?
Im gonna need benchmarks on that
Any examples exactly
Just search any expresss backwnd
How does that prove that you get more control in echoes
Express
in next.js all error will return 500: Internal Server Error
in Express you can modify the error code, what to do and the error message
this alone should be enough to tell you that express is more low level, less abstracted, less opinionated therefore you have more control on the behavior of the server
anything thats striped of its abstracted fucntionality should have more control in general. Its fairly obvious already
Cant you specify the error status to be whatever you want. Pretty sure you can
res.status(404).json()
but what if i throw something uncaught?
Internal server error yes isn't that the default even in express
Or say you change the default like the code snippet you gave how is that a meaningful difference. Uncaught errors will all have the same error message
ya but you can change the default
its a meaninfgul difference because the level of control that you get in express is different from Next.js
Its pointless for me to really explain to you all the differences between express and Next.js back-end if you dont get the differences
u only gave a practically insignificant example of chanigng the default uncaught error message
this doesnt really prove your point
Well sure, feel free to explore, for me it already proves my point