Building real APIs with NodeJS for beginners (Part 1)

Mr. Leo
mr-leo
Published in
2 min readDec 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:

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

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

2. Project

  • name: string

3. Task

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

4. TimeLog

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

Notes:

  • 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.

Don’t hesitate to clap if you considered this a worthwhile read!

~ Happy coding with Mr. Leo ~

--

--

Mr. Leo
mr-leo
Editor for

Developer provides high quality product. Personal blog: https://www.mrleo.dev