-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
33 lines (25 loc) · 855 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* Babel polyfill to include regenerator runtime */
import 'babel-polyfill'
import express from 'express'
import bodyParser from 'body-parser'
import webpack from 'webpack'
import { MemoryStore, Api } from 'graphql-query-whitelist'
import whitelistUI from './src'
/* Get Express instance and set port */
const app = express()
const port = process.env.PORT || 3001
const host = process.env.HOST || 'localhost'
const compiler = webpack(require('./webpack.config'))
app.use(bodyParser.json())
app.use('/whitelist/api', Api(new MemoryStore()))
app.use(whitelistUI({
apiURL: '/whitelist/api/'
}))
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true
}))
/* Spawn server */
app.listen(port, () => process.send
? process.send('online')
: console.log(`The server is accepting requests at http://${host}:${port}`))
export default app