diff --git a/README.md b/README.md index d9a8e60..cee208b 100644 --- a/README.md +++ b/README.md @@ -59,4 +59,19 @@ To run this server you will need: - utils -> Provide utility functions that can be called by services. - configs -> Provide configuration details for other files. - static -> Holds files for static service, should be hosted behind a caching proxy. + +## Configuration: +The app is designed to be run within Kubernetes or within a Docker container, as such configuration is provided with environment variables. See the variable name and default options below. If a required configuration is not present the program will exit. + +|VAR|DEFAULT|REQUIRED|PURPOSE| +|:-:|:-----:|:------:|:-----:| +|OWL_SRV_PORT|8460|NO|Web Server Port| +|OWL_SRV_LISTEN|0.0.0.0|NO|Web Server Listen Address| +|OWL_DB_USER||YES|Database Username| +|OWL_DB_PASS||YES|Database Password| +|OWL_DB_NAME||YES|Database Name| +|OWL_DB_PORT||YES|Database Server Port| +|OWL_DB_HOST||YES|Database Server Host| +|OWL_LDB_KEY||YES|National Rail LDBWS API Key| +|OWL_LDB_SVKEY||NO|National Rail LDBSVWS API Key| \ No newline at end of file diff --git a/src/configs/database.configs.js b/src/configs/database.configs.js index db6e28f..1980ccf 100644 --- a/src/configs/database.configs.js +++ b/src/configs/database.configs.js @@ -1,3 +1,9 @@ +OWL_DB_USER +OWL_DB_PASS +OWL_DB_NAME +OWL_DB_PORT +OWL_DB_HOST + const database = { user: 'owlboard', password: 'owlboard', diff --git a/src/configs/server.configs.js b/src/configs/server.configs.js index 8f960cc..1d13c83 100644 --- a/src/configs/server.configs.js +++ b/src/configs/server.configs.js @@ -1,6 +1,26 @@ +function getPort(){ + if (process.env.OWL_SRV_PORT){ + var confPort = process.env.OWL_SRV_PORT; + } else { + var confPort = 8460; + }; + return Number(confPort); +} + +function getListen(){ + if (process.env.OWL_SRV_LISTEN){ + var confListen = process.env.OWL_SRV_LISTEN; + } else { + var confListen = "0.0.0.0" + } + return confListen; +} + const server = { - port: 8460, - listen: "localhost" + port: getPort(), + listen: getListen() }; -module.exports = server; \ No newline at end of file +module.exports = { + server +} \ No newline at end of file