AdonisJS updates logo

AdonisJS updates

Subscribe
Archives
September 30, 2024

We have some new packages to share with you

Hello everyone!

It’s been a long time since I shared an update. A lot has happened during the past few months, so give me a moment to summarise it all for you.

Let’s start with some bigger releases.

FlyDrive - A file storage library for Node.js

In previous versions of AdonisJS, Drive was coupled with the framework. However, we have made some efforts to abstract Drive to be a framework-agnostic library and then created a thin wrapper on top of it for AdonisJS.

FlyDrive provides a consistent API for managing user-uploaded files on various storage services, such as S3, Google Cloud Storage, Cloudflare R2, and the local file system.

Documentation . AdonisJS wrapper


Transmit - Realtime broadcasting using SSE

We have added another first-party package to our collection. Transmit uses SSE (Server-sent Events) to broadcast events from the server to the client. As a result, you can build realtime applications without dealing with the complexities of WebSockets.

Transmit also comes with a sync engine to broadcast events from multiple processes. For example, you can broadcast events from a Queue worker after a Job has finished.

Documentation


Health checks

Health checks are now available in AdonisJS v6 and are part of the framework core (i.e., the @adonisjs/core package).

You start by registering the checks you want to perform and expose the results through an HTTP endpoint.

Documentation

new HealthChecks().register([
  new DiskSpaceCheck(),
  new MemoryHeapCheck(),
  new DbCheck(db.connection()),
  new DbConnectionCountCheck(db.connection()),  
  new RedisCheck(redis.connection()),
  new RedisMemoryUsageCheck(redis.connection())
])
import router from '@adonisjs/core/services/router'
router.get('/health', [
  () => import('#controllers/health_checks_controller')
])

Dump and Die

Dump and Die (dd) is a handy utility for printing JavaScript data types for debugging. Think of it as console.log but with a few improvements.

  • DD shows the file and the line number from where the log was written.
  • There is also an HTML viewer that allows users to view the output in the browser with the ability to collapse/expand nested data structures.

Documentation


Defer - In memory background queue

Defer is a neat package for running async operations in the background using an in-memory queue. Think of it as setImmediate but with support for monitoring, error handling, and graceful shutdown of the process by flushing the queue.

You can use it to perform non-critical tasks like refreshing the cache while serving stale content or removing expired data from the database.

import { DeferQueue } from '@poppinss/defer'
const queue = new DeferQueue()

queue.push(async function taskOne() {
  console.log('Running in the background')
})

Repo and Docs


New splash screen

We crafted a well-designed Splash screen that you see after creating a new application and running the dev server.

splash_screen.jpeg

Estéban (a fellow AdonisJS lover) did the design and implementation using TailwindCSS. Here’s the related PR


Community highlights

Remix + AdonisJS = ❤️

I came across this fantastic project that seamlessly integrates Remix inside an AdonisJS project. Alongside the integration, the documentation also covers some best practices to ensure you never bundle your AdonisJS application code within a Remix app.

If you love writing React and believe in the Remix Philosophy, do give this project a try — it looks promising.

Website

Queues

If you are looking to implement queues in one of your AdonisJS applications, you may want to try one of the following packages, which works seamlessly with v6 and uses BullMQ under the hood.

  • KABBOUCHI/adonisjs-jobs
  • rlanz/bull-queue

ShopKeeper

ShopKeeper is an all-in-one subscription management SDK built on top of Stripe. It can swap subscriptions, handle cancelling grace periods, manage coupons and can also generate invoices.

Documentation


Documentation improvements

  • Improve the overall structure and grouping of different topics.
  • Add OG (Open Graph) images
  • A guide on Creating Layouts using Edge components.
  • Community managed Japanese translation of docs.

Other notable releases

  • Support for Env identifiers
  • Run the AdonisJS Dev server in HMR mode
  • Introducing the env:add command to define environment variables and their validation rules.
  • Support for LibSQL
  • Beta support for ESLint 9
  • Edge.js stacks
  • Hot-hook: Throw when boundary file is not dynamically imported
Don't miss what's next. Subscribe to AdonisJS updates:
GitHub X
Powered by Buttondown, the easiest way to start and grow your newsletter.