0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 16:22:44 +00:00
Files
homebrewery/server.js
Alexey Sachkov 8895b44be9 [NFC] Outline an express app into a separate module
This is done in order to be able to re-use that app in API unit tests later
2022-01-11 22:24:23 +03:00

18 lines
544 B
JavaScript

const DB = require('./server/db.js');
const server = require('./server/app.js');
const config = require('nconf')
.argv()
.env({ lowerCase: true })
.file('environment', { file: `config/${process.env.NODE_ENV}.json` })
.file('defaults', { file: 'config/default.json' });
DB.connect(config).then(()=>{
// Ensure that we have successfully connected to the database
// before launching server
const PORT = process.env.PORT || config.get('web_port') || 8000;
server.app.listen(PORT, ()=>{
console.log(`server on port: ${PORT}`);
});
});