DEV Community

Amalia Hajarani
Amalia Hajarani

Posted on

Customer: Use Case for Learning Simple CRUD on ExpressJS and NestJS and The CI Pipeline (Use Case Introduction)

Hello dear reader. Today I have new use case to learn ExpressJS and NestJS and I think it's quiet beginner friendly since I have no experience in NestJS. We are just going to create a simple CRUD application and save it into PostgreSQL database. You can find the working repository here.


Before diving deeper, I want you to know that I will be using two different ORMs, Sequalize for ExpressJS and TypeOrm for NestJS. As I haven't work with node backend environment for so long, I have few resources that I read to build my application.

  1. Node.js Express & PostgreSQL: CRUD Rest APIs example with Sequelize
  2. Clean Node.js Architecture —With NestJs and TypeScript

Please check them out since of course they have better explanation.

Brief explanation

This is a painless usecase once you know how each ORM works and since again, it just a simple CRUD application. Below is how I structured my customer data to be use on every services:

    id: number,
    no: string, //uuid
    nama: string, //nama means name
    alamat: string, //alamat means adddress
    kota: string //kota means city
    createdAt: Date,
    updatedAt: Date
Enter fullscreen mode Exit fullscreen mode

For summary, we are going to make same functionality for both service which are:

  1. Create new customer
  2. Get all customers
  3. Get a customer by id
  4. Update a customer based on the id
  5. Delete a customer based on the id

Project structure

Since we are going to be running some CI (Continuous Integration) using Jenkins, this is my kind of project structure:

    ├── express-service/
    ├── nest-service/
    ├── front-end-service/
    └── Jenkinsfile
Enter fullscreen mode Exit fullscreen mode

Tips from a beginner:

Since one of our goal is to have CI run, we will have to push our code to a Git repository. It's much better if you push your work everytime you create a new functionality so you don't have to worry about losing your job!

Top comments (0)