April 2018
Beginner
226 pages
4h 47m
English
In Node.js, you can define your metadata as constants and use it in your application across the modules. To implement it consider the following snippet that is used to start a basic server in Node.js:
const http = require('http');const constants = require('./constants');const port = constants.port;http.createServer((req, res) => { res.end(`Hello ${constants.audience}`);}).listen(port);console.log(`Node Server is running on port : ${port}`)
We have already studied node servers in the previous chapter. Just to describe in brief the code creates an HTTP server and listens for incoming requests on specified ports locally. Unlike that example, in the Chapter 6, Building the Carousel Application, we have imported a constants ...
Read now
Unlock full access