Creating Our RESTful API

A web application is composed of different layers; upto now, you have been developing the client-side layer of the FIFA World Cup project. However, just presenting a user interface to the user is not enough. We need to process some business logic in order to provide an appropriate user experience to our users, such as subscribing to the next matches, retrieving the roaster for the user's favorite team, managing login, and more.

In order to have a full web application, we should implement the following server-side missing pieces in our project:

  • The RESTful API layer
  • Database layer

Once upon a time, developers used to implement all the layers in a single project, and this was because of the adoption of popular open source web platforms such as XAMPP, which configures a PHP/MySQL environment in just a few seconds. So, developers used to write the client-side web pages in PHP and add HTML code in the same file, mixing server-side with client-side code.

With the passing of the years, new techniques were introduced. Now, developers separate client side and server side in different projects, and in addition to separating the project, these layers are deployed in different domains. All of this was possible thanks to the introduction of new client-side and server-side frameworks. All this brings a new challenge—communication—so having separate projects now requires a way to exchange information with each other. RESTful APIs become the right solution to communicate between the client side and backend using the HTTP protocol as the mean of data transportation between these layers.

The following illustration depicts the new way to create web apps:

In this chapter, we will implement the RESTful API layer. For this, we will use Node.js and JavaScript to build a robust RESTful API. You will also learn the concepts and how to design robust APIs using an open source framework on top of Node.js called ExpressJS. We will also explore the new MEAN stack and learn about the technologies behind it and why we decided to baptize it as the new MEAN stack. Lastly, you will learn how to improve your RESTful APIs using new techniques to improve the developer experience in your team.

So, we will cover the following topics:

  • Understanding RESTful
  • Designing APIs
  • Creating an API with Node.js
  • Improving our API with ExpressJS
  • Coding our project
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.189.5