DEV Community

Chola
Chola

Posted on

My thoughts on ElysiaJS

Bun in the Oven

Before the Oven

My background in Graphic Design and Motion Graphics has drawn me closer to frontend development as the next step in my career, I've found myself really comfortable working in the UI/UX space, but of late after designing a few mobile app's, I developed an urge to learn how apps connect to the rest of the world, I experimented with Backend-as-a-Service systems (BaaS) such as Appwrite, Supabase and Firebase, these left me with an even deeper hunger to want to learn how backend systems work.

ExpressJS logo

I had tried ExpressJS in the past, I understood the concept of it but never really had the interest in working with backend systems until recently when I discovered NestJS - A mature, progressive framework running on NodeJS. Having a background in Angular development myself, NestJS felt like home. I recommend it to anyone trying to get into the backend world.

Bun logo

100 degrees celsius

When I first read stories about Bun, I was really excited, not only because it was another "Node killer", but because of the story of it - being built from the ground up using more performant tools and housing even more libraries by default - unlike Node. It was the same excitement I had when I discovered Cinema 4D and Blender taking over from 3DS Max. Every once in a while great tools begin to show their age due to the foundations they were built on, it is that way in the human world, and also in the tech world, and funny enough I happen to be watching Cars 3 as I write this, which has a similar storyline.
Node is battle tested with over 13 years of development and perfection, meanwhile Bun only recently hit version 1.0 which will ofcourse have some minor issues here and there before it can truly take over the scene, but in it's current state it still shows off a massive improvement in requests per second, load times and several other benchmark tests.

Bun benchmarks

Backend on fire

Over time, the world will adopt Bun - I hope, even though as you read this blog, Bun cannot natively be installed on Windows OS, but I had no problems whatsoever installing it on Ubuntu 20 via WSL2 (Windows Subsystem for Linux). My main interest with Bun has been to try ElysiaJS, an "Ergonomic Framework for Humans", quite basically a faster and more capable ExpressJS, thanks mainly to Bun 😎

ElysiaJS statistics
The above image will explain it all - why I was eager to try Elysia. Don't get me wrong Nest is still an all-round production-ready and modern framework, not forgetting it's a breeze to use if you're familiar with Angular, and did I mention it's currently sitting at version 10.2.9?
Well, while at version 0.7.21, Elysia is still pretty impressive despite not having a CLi. I was able to fire it up and manually set up a module system which is basically a folder consisting of a Routes, Controllers and a Services folder, a regime I picked up from Nest, and even though setting up a Microservice should be possible with Elysia (manually) I am yet to try this, something that NestJS offers out of the box with ease!!

My Elysia server consists of a Users and Auth system that relies on Prisma ORM, PostgreSQL database and Lucia Authentication. To run my database locally I am using Laragon which requires an installation of Postgres as it doesn't come with one out-of-the-box, other than that everything else was a breeze except for one minor issue, Prisma is built for NodeJS and as such requires an installation of Node - for now atleast, once that is set up you're good to go!

From the documentation section of Elysia you will notice it offers several plugins that make Elysia even more capable, these include plugins such as

  • Eden, a secure way for your client to access backend functions
  • Swagger, an endpoint to view all your API endpoint documentation
  • GraphQL, tRPC, A query language for API's, end-to-end typesafe API's
  • CORS, Helmet, Bearer, JWT and CRON just to mention a few

All this comes on top of Elysia's pre-existing features which include:

  • Lifecycle hooks and data transformation,
  • Response validation using schemas (think of typescript interfaces),
  • File uploading and serving,
  • Error Handling,
  • Lazy-loading of modules,
  • Web Sockets,
  • Data streaming,

I will share my Elysia project soon and keep updating it as I go but you can have a look at it's current structure, pretty similar to ExpressJS 😎

Feel free to contact me for any questions or collaboration requests

Top comments (1)

Collapse
 
aspexp profile image
ASPeXP

Thank you for sharing, Is it possible for you to share your Elysia project? I think it would be good for me to have a guide from another perspective.