Step 10
Several libraries and frameworks are built on top of Node's HTTP module to improve and extend its functionality. ExpressJS is one of those frameworks. It promotes itself as a "fast, unopinionated, minimalist web framework for NodeJS." It is famous for building APIs quickly and easily.
We will now refactor our server to use Express instead of Node's HTTP module.
First, install it.
npm install express
Notice three changes as a result of installing Express:
- Express is added as a dependency to
package.json
- The
node_modules
is added to the root directory. Make sure to exclude this folder from your Git repository. - A
package-lock.json
is added to the root of your project.
You are familiar with all this, as you have seen them in previous chapters.