官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 正定县| 玉山县| 平阳县| 阳山县| 胶南市| 河间市| 攀枝花市| 新安县| 诏安县| 伽师县| 广汉市| 凉城县| 乐平市| 波密县| 定陶县| 延庆县| 噶尔县| 宜兰县| 安远县| 蓬安县| 宁阳县| 肥乡县| 建德市| 宜黄县| 浠水县| 淅川县| 屏东市| 方正县| 额敏县| 宁强县| 凤山县| 石景山区| 迁安市| 延庆县| 阿拉善左旗| 西平县| 固阳县| 浦江县| 基隆市| 米易县| 平顺县|