Gabriele Ferro Home

APIs and Microservices Project - Exercise Tracker - Part 1

Day 98: 13 December 2020

The back pain is over so I can get back to work!

I need to finish writing my presentation for the 6th OpenClassRooms project.

So to avoid back pain again, today I have allocated only two hours that I can entirely devote to freeCodeCamp.

This way, I can divide my time with the Pomodoro Technique and I also realize my speed in writing code.

**Today’s Progress:**

I use this simple Tomato Timer web application to track each session.

4 sessions of 25 minutes with 5 minutes break between each one = 2 hours

I already written the first three freeCodeCamp projects for the API & Microservices Certification:

I only have two more to go and today I started to write the Exercise Tracker Microservice.

With npm I installed three modules needed for the project:

  • body-parser
  • mongoose
  • mongoose-unique-validator

I created a new database on MongoDB Atlas and configured the account and accesses.

I had also created a collection but actually it is not necessary, because by specifying a model, the collection is created automatically.

I created the schema for the user and for the exercises to be tracked.

Then I created the .env file so I could connect to MongoDB without having to share personal information using the npm dotenv module.

Also I added the nodemon module to the project but only in development mode and not in production writing:

npm install --save-dev nodemon

Once finished the preparation phase of the project I wrote some routes.

For the moment:

  • We can POST to /api/exercise/new-user with form data username to create a new user. The returned response will be an object with username and _id properties.
  • We can make a GET request to api/exercise/users to get an array of all users. Each element in the array is an object containing a user's username and _id.
  • We can POST to /api/exercise/add with form data userId=_iddescriptionduration, and optionally date. If no date is supplied, the current date will be used. The response returned will be the user object with the exercise fields added.

Notable mentions:

I also have finished writing my presentation!


There are two days left in this challenge and it feels like I just started yesterday….

**Link to tweet:**

**Link to work:**

[twitter-follow screen_name='20Gabriele20']

June 2024


Gabriele Ferro Home
Copyright © Ferro Gabriele. All rights reserved.