How to do it...

Let's install Express and make sure that it works. Installation is basically trivial because it's just another npm package, so you just need a simple command:

npm install express --save
You can add a --verbose optional parameter to the npm command to get a more verbose output and be able to see that things are happening.

Next, let's redo our basic test server from the previous chapter, but using Express. And, yes, this is way overkill for such a simple feature, but we just want to check that we set everything up in the right fashion! Refer to the following code:

// Source file: src/hello_world.js

/* @flow */
"use strict";

const express = require("express");

const app = express();

app.get("/", (req, res) => res.send("Server alive, with Express!"));
app.listen(8080, () =>
console.log(
"Mini server (with Express) ready at http://localhost:8080/!"
)
);
..................Content has been hidden....................

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