Learn AdonisJS pt. 1

Learn AdonisJS pt. 1

The missing node.js framework

·

3 min read

Table of contents

No heading

No headings in the article.

Just like many other Node.js backend developers, I spend most of my time building REST API's with Express.js. It's a small, very easy to use HTTP library with a huge amount of middlewares and awesome, large community around it.

But I didn't enjoy working with it. Something was missing.

Express.js is just a small HTTP library. It accepts requests and returns responses. No matter how well it does it's job, applications I write are rarely just accepting requests and sending JSON responses.

I would install npm packages that provide additional functionalities that I needed, but at what cost? Every new project, I had to install and configure a lot of third party packages, which took a lot of time and energy. These packages were small and independent, with the exception of Express.js middlewares. It was very challenging to glue all of them together for days at end. It felt like building a Frankenstein's monster.

I haven't started building my app, and I already lost a week and lost my mind.

My needs have shifted from building minimal and fast apps, to building complete solutions from ground up in shortest amount of time possible. This also means that all the tools for the job would be readily available and easy to use.

This is not a novel idea. Frameworks like Laravel, Ruby On Rails or Django have solved this problem 20 years ago. I was ready to start my new project with one of these, but one thing held me back: Typescript.

I am not ready to give up on Typescript type system, as I use it regulary and rely heavily on them. Being able to hover over an object and see exactly what methods and attributes it contains, or getting a compile time errors for silly mistakes is something I am not ready to let go.

Having done some intense googling, a ray of hope shined upon me. A Typescript first, battery included, developer first, ergonomy and productivity first Typescript framework is discovered.

Enter AdonisJS.

AdonisJS is a fully featured MVC web framework for Node.js, built by Harminder Virk. It is a backend framework for building dynamic web applications using Typescript. Some of the things you can do with this framework are:

  • Handle HTTP requestts
  • Query the database
  • Migrate and seed the database
  • Authenticate users
  • Upload files
  • Send emails
  • Validate requests
  • Render HTML templates
  • Test your apps
  • Manage session and cookies
  • Compile and serve frontend assets
  • CORS, hashing, encryption
  • Translate and internationalize
  • Environment variables validation
  • CLI tools
  • VScode extension

All of this features are built in. AdonisJS team build and maintain all the first party modules that provide all these features, with great community modules coming up more and more.

No more hunting for packages, no more cumbersone project setup and configuration. AdonisJS has it all. Finally, I can be productive from the day one:

  • Project folder structure
  • Eslint
  • Prettier
  • Typescript
  • Webpack
  • Live realoding
  • .env
  • Database migrations
  • CLI

Everything else? Easy. Install package, run configuration command, I'm ready.

Me being lazy is whole other topic.

This is part one of learning AdonisJS series. Future posts will dig deeper in this framework so you can be productive and enjoy using it.