Skip to content

Instantly share code, notes, and snippets.

@OutThisLife
Last active November 28, 2018 03:56
Show Gist options
  • Save OutThisLife/def4bc357c87ee15b9e776a546642ce0 to your computer and use it in GitHub Desktop.
Save OutThisLife/def4bc357c87ee15b9e776a546642ce0 to your computer and use it in GitHub Desktop.
import { spawn } from 'child_process'
import * as express from 'express'
import * as LRU from 'lru-cache'
const app = express()
const cache = LRU({
max: 152,
maxAge: 36e2
})
try {
const server = app
.use(require('../app/server/schema')({ app, cache, dev: false }))
.listen(3e3, err => {
if (err) {
throw err
}
console.log('> GraphQL server started; running export')
const build = spawn('next', ['export', './app'], {
stdio: 'inherit',
shell: true
})
build.on('close', () => {
console.log('> Export done; closing server')
server.close()
process.exit(0)
})
})
} catch (err) {
console.trace(err)
process.exit(1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment