#Api

1 messages · Page 1 of 1 (latest)

lucid bear
#

@river osprey How is the next api routes any different than a dedicated backend

terse elm
#

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

lucid bear
river osprey
#

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

lucid bear
#

Im gonna need benchmarks on that

terse elm
#

you have more control in express

#

thats it

lucid bear
terse elm
lucid bear
#

Express

terse elm
#

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

lucid bear
#

res.status(404).json()

terse elm
#

but what if i throw something uncaught?

lucid bear
#

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

terse elm
#

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

lucid bear
#

u only gave a practically insignificant example of chanigng the default uncaught error message

#

this doesnt really prove your point

terse elm