Gabriele Ferro Home

Completed the APIs and Microservices Course on freeCodeCamp!

Day 93: 4 December 2020

**Today’s Progress:**

I continue to study backend programming to alleviate my Imposter Syndrome.

I already completed the first part and today's goal was to complete the course on freeCodeCamp regarding APIs and Microservices.

I completed the part about Express and I wrote the last three middlewares.

Middlewares I wrote for the course on express

The first middleware shows the current date when visiting

The second middleware shows how to display the parameter sent from the address bar

The third middleware shows how to get data from a POST request and the route method.

I usually put every function in a separate folder called "controller" and then I export them. I create a router that links the controller function to each route and doing so I can separate the routing logic and the inner working of each function.

The first part talked about Node.js and Express, while the second part introduces databases using MongoDB.

MongoDB is a NoSQL database and it uses JSON instead of SQL tables to store the information.

Mongoose is a npm module (a collection of JavaScript files that we download) that simplifies writing the interactions between MongoDB and the Node server. For example we can create a Model (or Schema) that will allow us to instantiate an object from it.

A schema of a person with name, age and favorite foods.

I prefer to dedicate a single file for every Schema and export them.

Once we have our model in place we can write the code for common CRUD operations. For example we can:

  • create a person and store the informations in our database
  • create multiple persons starting from an array of people
  • find a person by name
  • find a person who likes a specific food
  • find a person by ID (unique number assigned to each record in our database)
  • find a person by ID and add a dish to their list of favorite foods
  • change the age of a person
  • delete a person from our database by ID or name
  • and chain several filters
Basic CRUD operations

I always used the then & catch methods to return a Promise and send a response status and a JSON message, but now I discovered this alternative of passing a callback!


Having followed the "same" course on OpenClassRooms and on freeCodeCamp I appreciate both methods.

On freeCodeCamp the learning approach is progressive and simpler overall.

While on OpenClassRooms at some point the course gives for granted certain concepts, but also, it suggests a structure for our project that looks way more complex and professional to me.

**Link to tweet:**

[twitter-follow screen_name='20Gabriele20']

July 2024


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