-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Idea: Target idiomatic JS instead of NodeJS to be able to run on any environment #36
Comments
We actually use a well known architecture from enterprise Java -- Java's Spring Boot -- behind the scenes. In this architecture the HTTP server and end points are mapped to the actual code using language annotations. We implemented almost identical annotations as in Java Spring Boot to our implementation for TypeScript. See examples in HsBackendController.ts. Our annotatios are also designed to be separate from the implementation that implements the HTTP server side. This design allows different implementations for different platforms as well as possible complete rewriting later for better implementation and performance -- without any changes to any application code we might have already written. We could for example implement direct Nginx server plugin later to run our backends with Nginx instead of NodeJS (Nginx already has Google v8 JS engine support and we've done projects using it). So the application code in So far we have only one implementation of our I also like to design most of our code using common interfaces which also make it possible to write different implementations later and make it possible for our code not to be dependable of any specific adapter implementation. Another big layer is the persistent data storage. We will use our Repository interface in |
So TLDR in general, we can actually quite easily compile different versions of |
oh ok sorry I didn't see that you already had an abstraction in place through Java, that's great! |
There is no Java involved -- it's just implemented with the same public API specs as in Java's Spring Boot, but for TypeScript :) We have some documentation at fi.hg.core's README but sure, it could be better. |
oh ok interesting! |
Hi, I was wondering how possible would it be to not depend on NodeJS specific APIs directly and instead write idiomatic JS with a small abstraction layer similar to what Remix does with their "server adapters" here: https://remix.run/docs/en/v1/other-api/adapter
That would allow to deploy to all the new cloud on the edge that don't support NodeJS (e.g. cloudflare, vercel, fly.io, ...). It would also make it possible to use other JS runtimes like Deno or Bun, and potentially even run natively on mobile or desktop with something like react native or electron.
If you think that would be useful then it would be easier to make that move earlier than later before the codebase gets much bigger.
The text was updated successfully, but these errors were encountered: