The Ultimate backend with NestJS (Revisited)


Over the past few years, I've tried many different solutions for my personal blog from static site generators like Gatsby, Hugo, Jekyll and many others to NextJS and KeystoneJS. But, when it came time to build something that would last me well into the future I decided to go full DIY. Using the excellent NestJS framework, their docs and a tutorial published by FreeCodeCamp I was able to build my personal blog with authorization, authentication and a fully-featured rich text generator.

Building my own backend API I was able to get several features that were previously beyond my reach which included deep integration with a React frontend with the aforementioned authentication and the fact that the rich text editor I was using is compatible with JSX components exactly like those I planned to use to structure the posts.

NestJS has a variety of extremely helpful packages like OpenAPI, PassportJS and GraphQL modules which are all maintained by the same team behind Nest. But, by far the most helpful thing was their documentation which allowed me to get up and running quickly and build a feature set that was truly more akin to a production application.

Using experimental features like TypeScript decorators NestJS is able to obtain something I would describe as being similar to the very few asp.net applications that I've seen, with almost the entirety of its structure built using decorators. By combining these decorators with Nest's very own implementation of DTOs through TypeScript classes annotated with decorators it's also able to do server-side validation with ease, simply by annotating the chosen DTO property with one of the very many decorators provided by class-validator.

As NestJS evolves we will undoubtedly see its use become more widespread and more popular than the traditional ExpressJS boilerplate that most TypeScript APIs are built using.

What's great is that the NestJS framework is also able to be used by other projects like command-line tools and projects like discord-nestjs.