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

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.

主站蜘蛛池模板: 孝感市| 丹棱县| 麻阳| 康马县| 龙江县| 玉环县| 绵竹市| 德昌县| 雅安市| 鹤庆县| 望谟县| 长宁县| 姜堰市| 金华市| 抚远县| 阿坝| 临漳县| 南岸区| 铜山县| 汉寿县| 百色市| 晋州市| 青州市| 个旧市| 陇西县| 普兰县| 丰台区| 临江市| 卫辉市| 松滋市| 夏邑县| 永安市| 齐齐哈尔市| 镇宁| 南宁市| 胶州市| 金湖县| 曲阳县| 临颍县| 临桂县| 怀仁县|