Skip to content

Instantly share code, notes, and snippets.

@OutThisLife

OutThisLife/export.ts

Last active Nov 28, 2018
Embed
What would you like to do?
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