const DEBUG=require('debug')('index'); const HTTPS = require('https'); const FS = require('fs'); DEBUG('index start...'); const APP=require('./app/app'); //set port const PORT=parseInt(process.env.PORT, 10)||65535; DEBUG('index: PORT: ' + PORT); //pass 'APP' to server DEBUG('index: NODE_ENV: ' + process.env.NODE_ENV); if (process.env.NODE_ENV !== 'production') { DEBUG('index: development mode'); APP.listen(PORT); }else{ DEBUG('index: production mode'); HTTPS.createServer({ //TODO make key and cert available via config key: FS.readFileSync('./p'), cert: FS.readFileSync('./f') }, APP) .listen(PORT, ()=>DEBUG('index: listening on port '+PORT)); } DEBUG('index: index done.');