README
config-sets: simple configure library
Configure the app easily.
Installing
npm install config-sets
Usage example
config-sets.json //in working folder
{
"production": {
"isDebug": false,
"port": 8080,
"launch_url": "/"
},
"development": {
"isDebug": true,
"launch_url": "/options"
}
}
app.js
var options = require('config-sets').init({
port: 3000,
launch_url: "/"
});
console.log('isDebug:' + options.isDebug);
console.log('profiler:' + options.profiler);
require('http').createServer(function (req, res) {
if (req.url.startsWith('/options')) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end(JSON.stringify(options, null, 2));
return;
}
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello, World!\n');
}).listen(options.port);
// Opens the URL in the default browser.
function openBrowser(url) {
var start = (process.platform == 'darwin' ? 'open' : process.platform == 'win32' ? 'start' : 'xdg-open');
require('child_process').exec(start + ' ' + url);
}
openBrowser(`http://localhost:${options.port}${options.launch_url}`);
select development settings
$env:NODE_ENV="development"
or
set NODE_ENV=development
select production settings
$env:NODE_ENV="production"
or
set NODE_ENV=production
License
Copyright (c) 2021 Manuel Lõhmus manuel@hauss.ee