const debug = require('debug')('node-express-base'); const libs = `${process.cwd()}/libs`; const config = require(`${libs}/config`); const log = require(`${libs}/log`)(module); const app = require(`${libs}/app`); const compatVersion = require(`${libs}/middlewares/checkVersion`); // Check if Node version is compatible if (!compatVersion()) { process.exit(1); } // Set default port: first environment variable PORT, then configuration and last 3000 app.set('port', process.env.PORT || config.port || 3000); process.env.NODE_ENV = process.env.NODE_ENV || 'development'; // Set default ip: first environment variable IOP, then configuration and last '127.0.0.1' app.set('ip', process.env.IP || config.ip || '127.0.0.1'); const server = app.listen(app.get('port'), () => { log.info(`Express server listening on port ${server.address().port}`); }); // For testing module.exports = server;