Package Exports
- config-sets
- config-sets/browser.js
- config-sets/index.min.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (config-sets) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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=developmentselect production settings
$env:NODE_ENV="production"or
set NODE_ENV=productionLicense
Copyright (c) 2021 Manuel Lõhmus manuel@hauss.ee