Oracle Magazine, May/June 2018
Database Developer OPEN SOURCE ORACLE MAGAZINE MAY JUNE 2018 92 port process env HTTP_ PORT 3000 This is a simple JavaScript module that exposes a single property named port In Node js the process object has an env property that contains the user environment Im using that to set the value of port to the value of the environment variable HTTP_ PORT If that environment variable isnt defined the default value will be 3000 Its common to derive port values from environment variables because they may vary in different environments or be randomly assigned at runtime With the configuration file ready you can turn your attention to the web server module Open the services web server js file in gedit Copy and paste the following code into the file and save your changes const http require http const express require express const webServerConfig require config web server js let httpServer function initialize return new Promise resolve reject const app express httpServer http createServer app app get req res res end Hello World 1 2 3 4 5 6 7 8 9 10 11 12 13
You must have JavaScript enabled to view digital editions.