mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-02 06:22:43 +00:00
Add config items
Add config items and default values: - web_port (8001) - environment (local)
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"host" : "homebrewery.local.naturalcrit.com:8000",
|
"host" : "homebrewery.local.naturalcrit.com:8000",
|
||||||
"naturalcrit_url" : "local.naturalcrit.com:8010",
|
"naturalcrit_url" : "local.naturalcrit.com:8010",
|
||||||
"secret" : "secret"
|
"secret" : "secret",
|
||||||
|
"web_port" : 8001,
|
||||||
|
"environment" : "local"
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,11 @@ const config = require('nconf')
|
|||||||
.file('environment', { file: `config/${process.env.NODE_ENV}.json` })
|
.file('environment', { file: `config/${process.env.NODE_ENV}.json` })
|
||||||
.file('defaults', { file: 'config/default.json' });
|
.file('defaults', { file: 'config/default.json' });
|
||||||
|
|
||||||
|
if ( !process.env.NODE_ENV && config.get('environment') ) {
|
||||||
|
process.env.NODE_ENV = config.get('environment');
|
||||||
|
console.log('NODE_ENV set from config')
|
||||||
|
}
|
||||||
|
|
||||||
//DB
|
//DB
|
||||||
const mongoose = require('mongoose');
|
const mongoose = require('mongoose');
|
||||||
mongoose.connect(config.get('mongodb_uri') || config.get('mongolab_uri') || 'mongodb://localhost/naturalcrit',
|
mongoose.connect(config.get('mongodb_uri') || config.get('mongolab_uri') || 'mongodb://localhost/naturalcrit',
|
||||||
@@ -232,6 +237,6 @@ app.use((req, res)=>{
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const PORT = process.env.PORT || 8000;
|
const PORT = process.env.PORT || config.get('web_port') || 8000;
|
||||||
app.listen(PORT);
|
app.listen(PORT);
|
||||||
console.log(`server on port:${PORT}`);
|
console.log(`server on port:${PORT}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user