Node JS Express for FrontEnd Developers a Practical Guide: Overview and Motivation

In ReactJS for Angular Developers a Practical Guide: Overview and Motivation, I explained how after a long period working with Angular, I felt I should reacquaint myself with React. I started by looking at my React project repos on Github. This proved to be a frustrating experience because, after seven years of working exclusively in one framework, it was nearly impossible to understand what I had written in the other. I had no choice but to relearn everything from scratch. Eventually, I was able to build a sample task management. After achieving my initial goals, I felt sufficiently competent in React to move on to other things. When I next revisited the project, I had a general idea of what everything did but understanding what I had created required more effort than I expected.

To avoid repeating the same mistake, I decided to create a practical guide to learning React based on the code I had written. I took the project and broke it down into smaller mini-projects. Each mini-project would illustrate specific React features with each new project building on the knowledge acquired in the previous step. The result was ReactJS for Angular Developers.

 

For each article in the series, I wrote sample Angular code to illustrate how to perform this functionality in Angular. As a long-time Angular developer, this forced me to reexamine some of my assumptions regarding Frontend development. An additional benefit of writing Angular examples was that it allowed me to learn the latest version of Angular. It also inspired me to write another series, Angular for React Developers where I took a similar approach but from the opposite direction.

Now I covered the basics of building web applications with React and Angular, I thought that I should move from the frontend to the backend. At this point, both series interact with and display data from static files and my intention for both series was to teach how to work with REST APIs. In addition, I recently learned how to build a REST API using Node.JS, Express, and Mongodb. In order to avoid my original mistake of learning something, and having to learn it again, I’m launching a new mini-series, on creating a NodeJS backend. As with my previous series, I will be looking at Node from the perspective of a frontend developer. Once I complete this series, I will be publishing new installments of my Angular and React series.

 

The tutorial includes the following installments:

  • Part 1 Getting Started:In this first part, we will install our development environment, create an index.js file, and write the initial application code.
  • Part 2 Building an API:In the installment, we create a User API that returns a list of all Users, returns a single user, and login.
  • Part 3 Understanding Routing:In this installment, we reorganized our code and created a modular API. This will make it easier to manage and extend our task management API.
  • Part 4 Querying and Managing Tasks:In this installment, we create a task API and explored how to create routes with default and optional parameters. In addition, we implement task management functionality using HTTP POST, PUT, and DELETE commands.
  • Part 5 Managing Data with MongoDB:In this installment, we integrate the User API with MongoDB. We started by installing MongoDB, creating a database, and populating the users collection. Next, we will create a Mongo module that enables us to query a single item or items from MongoDB. We conclude this installment by updating the Users module to take advantage of MongoDB.
  • Part 6 Task API Database Integration:In this installment, we create and populate tasksDB’s task collection. We update the mongo.js module to create and update tasks. We integrate tasks.js with MongoDB. This enhanced our existing querying functionality and to persist, update, and delete tasks from the database.
  • Part 7 Testing the API:In this installment, we investigate two testing approaches. The first approach used Postman as an HTTP client application to send data to individual routes. The second approach used the Jest and Supertest frameworks to write automated test scripts.
  • Part 8 Documenting the API with Swagger:Now we have a fully functional Task Management API that receives data and is able to query, persist, and modify that data using a database. We also have a complete test suite that tests all available API routes. All we are missing is documentation that demonstrates our API and shows us how to use it. In the final installment in this series, we will use Swagger to document our code.