November 2018
Beginner
132 pages
2h 57m
English
We will not go into much detail on this, as it was covered in the previous chapter. To start our server, we will simply insert the following content into the index.js entry file:
// ./index.jsconst Koa = require('koa');const app = new Koa();const port = process.env.PORT || 3000;app.listen(port, () => console.log(`Server running on http://localhost:${port}`));
The server either runs on a specified port with the PORT environmental variable or on the default 3000 port.
To start our application, you can run this command from the project root:
node index.js
Read now
Unlock full access