Nowadays APIs are everywhere, whether you like it or not, and if you are a software engineer, you cannot avoid REST API, that’s how incredibly common it is.

If you decide to create another API in Node.js you might be faced with a dilemma… which HTTP framework should I use? There are plenty of options including the most popular choices like express, koa, loopback… and NestJS.

NestJS is a framework for building  Node.js server-side applications. It comes out of the box with tons of great tools, lots of which were inspired by Angular like modules, services, dependency injection, CLI, pipes, and many more. By default, it uses TypeScript however you can use VanillaJS if you wish.

Today I would like to present a simple example of a clean REST API for managing books. Let me show you how beautifully organized it is with a little help from the  CQRS module from NestJS.

Click here for the Github repository.

First, we will take a look at the general structure, then we will analyze it step by step.

#nestjs #nodejs #javascript #api

Clean REST API with NestJS and CQRS
11.90 GEEK