Building real APIs with NodeJS for beginners (Part 1)

Dec 10, 2018

Learning new tech always makes us feel excited, and it will be more exciting if we can apply to our life by building a useful product. In this series, we can go through building APIs with NodeJS and Express steps by steps. Our expectations after finishing this series are:

  • How to analyze problems and provide solutions by yourself.
  • Reasonable organization Node project structure.
  • Authenticate APIs.
  • Writing APIs unit tests with Jest.
  • Using Docker for development and deploy to production.

All main contents in this series in case we want to navigate quickly:

  • From analyzing business domain to designing database models.
  • Setup Node project from scratch.
  • Using Sequelize & MySQL Docker image for development.
  • Organize project structure.
  • API Authentication with Passport.
  • Writing Unit test for API NodeJS by Jest framework.
  • Dockerize NodeJS application.

All these codes in this project can be found here.

From Analyzing Business Domain To Designing Database Models

Here is our scenario: most of us are working in outsourcing company. In the same time, we can work on multiples projects, and each project requires many tasks (of course). Every day, we (one user in our system) have a standup meeting that the meeting we’ll report what we did yesterday, for example.

Model design


  • name: string
  • password: string
  • role: string (value could be admin / normal)


  • name: string


  • name: string
  • point: integer
  • userId
  • projectId


  • timeInHour: decimal(3, 1)
  • userId
  • projectId


  • Task: point field in Task is what we usually estimate in Estimation meeting in Agile process
  • TimeLog: timeInHour is how many time in hour we spend on one project.

Checklist functionalities

Now we will create a checklist functionalities we want to complete for this project:

  • Create new user.
  • Login to get authenticated token.
  • List all users
  • CRUD tasks
  • CRUD timelogs
  • List tasks working per project per date.

That’s all basic requirements we need before going to coding time. See you in the next section.