The Paradox of Choice in NodeJS
The NodeJS ecosystem is rich with frameworks like NestJS, SailsJS, and Adonis. These frameworks offer extensive ecosystems of plugins and extensions, allowing developers to integrate databases, caches, and various services with ease. While this flexibility is powerful, it introduces a significant challenge: decision fatigue.
Simplicity is the ultimate sophistication
This timeless quote resonates strongly in today’s software engineering landscape. The current NodeJS ecosystem, fragmented with countless packages, often complicates development rather than simplifying it. Every developer has their preferences, leading to projects with varying architectures and dependencies.
The Need for Consistency
During NodeJS, I found myself working on Node projects with vastly different architectures. Experimenting with various packages made it challenging for my team to understand and build upon our codebase. This inconsistency hampered our ability to:
- Switch contexts quickly
- Debug efficiently
- Implement features rapidly
Learning from Other Ecosystems
Frameworks like Laravel and Ruby on Rails have kept PHP and Ruby relevant by offering superior features and an excellent Developer Experience (DX). Inspired by this, and particularly affirmed by a tweet from Taylor Otwell, I began to envision a similar solution for the NodeJS ecosystem.
The Birth of Intent
I will be honest, first version of Intent is an aggregation of my past open source works that I have been doing since 2020. It’s built on top of NestJS utilising it’s powerful Dependency Injection system and HTTP Server Implementation. Intent prioritizes Developer Experience (DX), and various integrations like FileSystems, Queues, Cache, etc.
Introduction
Intent is a web application framework built on top of NestJS. With built-in declarative and elegant APIs out-of-the-box, you can quickly build an production ready scalable application.
Some of the features that Intent supports out of the box.
Integration | Drivers |
---|---|
RDBMS | MySQL, Postgres, Sqlite |
Storage | Unix File Systems, S3 |
Message Queues | AWS SQS, Redis |
Mailers | SMTP, Mailgun, Resend |
Caching | Redis, In-Memory |
Console Commands | |
Logging | File Based Logging |
Exception Handler | Sentry Integration |
Validations | |
Transformers | |
Helpers | Number, Array, Objects and Strings |
Internationalisation |
Let’s take a quick look at how quickly you can use these integrations.
Database Integration
DB Introduction here.
Using Storage
Intent supports UNIX File System
and AWS S3
right now. All you need to change is the configuration, and done. No change at the code level is needed.
Read More - Storage Docs
Message Queues
For any async tasks, Intent provides support for Redis-based, AWS SQS message queues. Let’s take a quick look.
First, define a job with Job
decorator.
Now, we need to dispatch this job to the queue.
Now you can start consuming the messages using node intent queue:work
command in terminal.
Read More - Queue Docs
Mailers
Intent comes with an in-built email template which you can use to build emails. For example,
Above code will output the following email,
Now you can simply send the email with any of the support drivers (Resend, Mailgun, SMTP).
Read More - Mail Docs
Caching
Intent comes out of the support for Redis
and In Memory
cache database. Let’s see how quickly you can start using cache.
You might also run into situations where the data doesn’t exist in the cache, then you can use the remember
or rememberForever
method.
Read More - Cache Docs
Console Commands
You can also write elegant console commands using Intent which you can run in your terminal using node intent command_name
.
Now you can run the command in your terminal
Read More - Console Docs
Logging
Intent comes with support for file based logging, You can make use of the file based logging. Let’s take a quick look,
Read More - Logging Docs
Exception Handler
Intent comes with global exception filter for your application, along with integration for Sentry enabling you to track and notify you of errors whenever they happen on production.
Read More - Error Handling
Transformers
Intent comes with support for Transformers
which you can use to transform the response objects before you send it out to the client,
the clients can also request for additional data on the fly.
You can read more about it here.
Helpers
I have added multiple helper methods which I feel would be very useful, so that you don’t have to pollute your code with small logic.
For example, let’s take a look at Numbers
helper
It also has String
helpers, for example.
If you want to pull some keys from nested objects
, you can do so
Similarly, you can also use Array
helpers, let’s say you want to return the array but without some keys.
Read more - Helpers Doc
Internationalisation
If you would like integrate localisation in your application, you can easily do so by just defining your lang_code.json
file inside resources/lang
directory.
Now you can request for translated strings using __
helper.
Localisation also supports parameterisation, pluralisation out of the box, you can read more about it here.
Licence
Intent is licensed under MIT © HanaLabs
Have an idea? I can help you build it
Send me an email at hi@vinayaksarawagi.com, whatsapp me or just drop your email address below and I will get back to you!