Bhaumin
Bhaumin5w ago

Routes with Deno and Fresh

For web application using deno and fresh, what is recommended to serve backend api? Deno serve or fresh? What are the key trade-offs between Deno's serve and Fresh in terms of Performance & Scalability?
14 Replies
marvinh.
marvinh.5w ago
Fresh uses Deno.serve under the hood If you only need to serve a backend API hono or oak are probably the best fit you can always handle everything manually yourself by going with no framework and just the Deno.serve API
Bhaumin
Bhaumin5w ago
hey thanks for the reply. we are going to serve frontend and backend both.. so wanted to know that is it possible to have only one ts file which serves fresh for frontend and deno serve native routing for backend? and if fresh uses Deno.serve under the hood then if we use fresh for both frontend and backend is there any trade offs in terms of performance?
marvinh.
marvinh.5w ago
No there are no tradeoffs from a pure performance perspective.
Bhaumin
Bhaumin5w ago
What's advisable? Using fresh for routing all the things in saas like frontend, backend and everything?
marvinh.
marvinh.5w ago
It really doesn't matter which option you pick. You can use Fresh to route all the things, you can also have your own router and shell out to Fresh, etc. I'd be reaaaaaallly surprised if you could even measure a difference between the two approaches
Bhaumin
Bhaumin5w ago
What do you suggest?
marvinh.
marvinh.5w ago
pick the approach you prefer more. You cannot make a wrong choice
Bhaumin
Bhaumin5w ago
Haha... What will you suggest for the best possible performance? Should we adopt fresh for all? Or should we implement things based on deno serve? Or should we build our own router for everything? Or should we adopt a url paths based router?
marvinh.
marvinh.5w ago
You're overthinking it. There is no difference in performance between the approaches. You can pick any of the options you have listed and you'll reach your goals It's not a technical decision, instead it's a decision that depends much more on what your team's size is. What's the level of knowledge in that team, etc. From a pure technical viewpoint there are zero differences when it comes to perf whatever approach you pick
Bhaumin
Bhaumin5w ago
Okay thanks a lot for clarifying. So the conclusion is good to go with fresh for all types of routing also as of now. Right?
marvinh.
marvinh.5w ago
yeah that's a perfectly good option, like all the other one's of yours
Bhaumin
Bhaumin4w ago
Okay thanks @marvinh. We want to route traffic from the main.ts only for all the sub domains and for frontend and backend of all subdomain and main domain also Like domain.com Api.domain.com Docs.domain.com Admin.domain.com Then what should be main TS code like async manner to handle traffic or how? Can you please help to implement this? And is this the right approach or not? @marvinh. Can you please help us here?
marvinh.
marvinh.4w ago
Always happy to help with any Deno or Fresh specific questions. I'm afraid I don't have the bandwidth to go beyond that.
Bhaumin
Bhaumin4w ago
haha ok thanks