This module helps you to work with the config file
npm install gh-config --save
npm install gh-config
[
{
"HOST": "localhost"
},
{
"PORT": 3000
}
]
const config = require('gh-config');
put __dirname and path to your config file in parameters.
config.connect(__dirname, 'path to the config file');
returns the value of object in config. put key of object in parameters.
let HOST = config.get('HOST');
add new object to the config file put new object in parameters
config.add({"host": "localhost"});
delete object in the config file put ke of object in parameters
config.delete('HOST");
returns all config file
let fullConfig = confog.getFull();
const express = require('express');
const config = require('gh-config');
const app = express()
config.connect(__dirname, './config.json');
const PORT = config.get('PORT');
app.get('/', (req, res) => {
res.send('Hello World ! ! !');
})
app.listen(PORT, () => {
console.log(`Server started on port: ${PORT}`);
})