Created
July 11, 2017 08:17
-
-
Save smooJitter/0d2f0876184bf856aadd2fc30b54d2cd to your computer and use it in GitHub Desktop.
This binds the specified paths to the Express server running Guru + GuruiQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Application Server | |
*/ | |
import express from 'express'; | |
import { WebApp } from 'meteor/webapp'; | |
import main from './main'; | |
export default async function server () { | |
try { | |
const app = express(); | |
const os = require('os'); | |
const networkInterfaces = os.networkInterfaces(); | |
await main({ app }); | |
app.set('port', process.env.PORT || app.locals.port); | |
let externalAddress; | |
if (networkInterfaces.en0 === true) { | |
externalAddress = networkInterfaces.en0[0].address; | |
} else if (networkInterfaces.wlp4s0) { | |
externalAddress = networkInterfaces.wlp4s0[0].address; | |
} | |
const server = app.listen(app.get('port'), () => { | |
const port = server.address().port; | |
process.stdout.write(` | |
Guru Express server started in ${app.get('env')} mode. | |
Local address : http://localhost:${port} | |
${externalAddress ? 'External address ' + 'http://' + externalAddress + ':' + port : ''} | |
`); | |
}); | |
} catch (error) { | |
console.log(error); | |
} | |
// this binds the specified paths to the Express server running Apollo + GraphiQL | |
WebApp.connectHandlers.use(app); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment