NestJS materials

Write an awesome doc for NestJS tips, tricks, notes, things which are not in the doc (or are but not really obvious) and experimented to figure them out and use them.

View on GitHub

Complex Reservation

In this project we will write E2E tests, automating our tests and unit tests. To learn more about tests. Learn more about testing here. I also tried to have idempotent endpoints but it is rather cumbersome with NestJS and how it works. Just look at how I had to change the response status code here or how much effort I had to put into detecting whether this is a new document or should I update the existing one. It worth mentioning it that your everyday class-validator sucks at validating the incoming request. as you can see that I eventually had to do part of it in the service layer here and here. So all in all if I wanna be completely honest I would say it is too much effort. Just compare it to what I did for creating user, the difference is palpable.

BUT This does not mean that I am advocating against it since now my reservation service is idempotent and our client app can repeat just about anything when their initial request failed. Of course there are still features such as adding retry-after header to the response. I wanna emphasis on the fact that if you’re building an app for a very critical thing (things like financial apps, hospitals) where you need to be fail tolerant you probably need to consider it.

A reservation booking system that has the following features:

Topics that can be considered for further discussion

Learn more

Start the app in dev env

  1. pnpm i --frozen-lockfile
  2. Copy .env.example files and create .env files.
  3. pnpm compose:up.
  4. pnpm start.

Run E2E tests

  1. cp .env.example .env
  2. pnpm i --frozen-lockfile
  3. ./run-e2e.sh

Update 3rd-party libs

pnpm up --latest

Tech stack

Services

Libs

Common libraries that we’ll use in different microservices.