Queuing jobs in NestJS using @nestjs/bullmq package

Loading

Reading Time: 7 minutes Introduction Both Bull and BullMQ are queue libraries that persist jobs in Redis. Bull is in maintenance mode and maintainers only fix bugs in the library. The new version of the library, BullMQ, is rewritten in TypeScript. Bull and BullMQ are similar except BullMQ introduces flow producer that can split a resource-intensive job into children … Read more

Create NestJS health check library

Loading

Reading Time: 6 minutes Introduction NestJS applications in my company implement health checking for k8s liveness probe. These applications check the following items are up and running: backend, database, redis, bull queue and external servers. Eventually, different backend teams encapsulate similar endpoint and services in a heath check module and import it to the application. This approach is not … Read more

Check health of nestjs bull queue with terminus

Loading

Reading Time: 5 minutes Introduction It is common for enterprise applications to connect to external resources to process requests and get back responses. Therefore, application should know that the components it depends on are up and running all the times. Otherwise, the application behaves erroneously when serving client requests. To stay aware of the availability of connected resources, we … Read more

Queue and job processing in nestjs

Loading

Reading Time: 5 minutes Introduction The responsibility of backend application is to handle client requests and return responses back to the client. However, backend performance can degrade when the request is resource intensive; UI thread waits endlessly and user interface is blocked for further user actions. To avoid the unresponsiveness, we can place jobs in queue and delegate the … Read more

Lint files and dependencies in NestJs with unimported

Loading

Reading Time: 5 minutes Introduction When developers maintain a NestJS project, they add and delete codes to the project that some dependencies and files become redundant. When unused files and dependencies are left around, they become technical debts and reduce the code quality. Fortunately, we can use unimported to lint files and dependencies before git commit to avoid pushing … Read more

Create dynamic module made easy in NestJS 9

Loading

Reading Time: 4 minutes Introduction Our technology team builds a lot of Nestjs libraries to reuse in Nestjs applications. Our libraries provide forRoot() to create dynamic module only. Therefore, we cannot call forRootAsync() to register asynchronous module by importing modules and injecting services. Before V9, there are many boilerplate codes to get forRootAsync() to work. Internally, forRootAsync invokes createAsyncProvider … Read more

Generate i18n pdf invoice in nestjs app with nestjs-i18n

Loading

Reading Time: 7 minutes Introduction This project is a proof of concept (POC) to generate i18n pdf invoice using nestjs-i18n and html2pdf. In this use case, the i18n language comes from database instead of http request. It is because scheduled job generates and sends out invoices on a monthly basis that does not involve HTTP communication. After retrieving the … Read more

Add i18n translation to emails in nestjs app with nestjs-i18n

Loading

Reading Time: 6 minutes Introduction This project is a proof of concept (POC) to apply i18n translation to emails. Our vendor has a different solution to translate emails at work; therefore, this solution is not picked up. Nonetheless, I want to show my work in this post to demonstrate how to use nestjs-i18n library to translate the content of … Read more

Add i18n support in nest app with nestjs-i18n

Loading

Reading Time: 7 minutes Introduction Many enterprise applications support multiple languages nowadays to cater to customers whose first language is not English. In nest application, we would like to add i18n support to return i18n messages to client-side applications such that users can respond with appropriate actions. Nest framework does not have i18n out of the box but we … Read more