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.
Resources
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.
- Node.js Express & PostgreSQL: CRUD Rest APIs example with Sequelize
- 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
}
For summary, we are going to make same functionality for both service which are:
- Create new customer
- Get all customers
- Get a customer by id
- Update a customer based on the id
- 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:
simple-mini-project/
├── express-service/
├── nest-service/
├── front-end-service/
└── Jenkinsfile
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)