Node.js and Express.js

One primary goal of this book is to set up a GraphQL API, which is then consumed by our React front end. To accept network requests (especially GraphQL requests), we are going to set up a Node.js web server.

The most significant competitors in the Node.js web server area are Express.js, Koa, and Hapi. In this book, we are going to use Express.js. Most tutorials and articles about Apollo rely on it.

Express.js is also the most used Node.js web server out there and explains itself as a Node.js web framework, offering all the main features needed to build web applications.

Installing Express.js is pretty easy. We can use npm in the same way as in the first chapter:

npm install --save express

This command adds the latest version of Express to package.json.

In the first chapter, we created all JavaScript files directly in the src/client folder. Now, let's create a separate folder for our server-side code. This separation gives us a tidy directory structure. We will create the folder with the following command:

mkdir src/server

We can now continue with the configuration of Express.js.

..................Content has been hidden....................

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