Last active
November 28, 2018 03:56
-
-
Save OutThisLife/def4bc357c87ee15b9e776a546642ce0 to your computer and use it in GitHub Desktop.
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
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