You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
669 B
JavaScript
33 lines
669 B
JavaScript
5 years ago
|
const express = require('express')
|
||
|
const nextjs = require('next')
|
||
|
const {promisify} = require('util')
|
||
|
|
||
|
const dev = process.env.NODE_ENV !== 'production'
|
||
|
const next = nextjs({dev})
|
||
|
const nextRequestHandler = next.getRequestHandler()
|
||
|
|
||
|
;(async ()=>{
|
||
|
|
||
|
// Allow Next.js to compile its templates
|
||
|
console.log('Preparing Next.js templates . . .')
|
||
|
await next.prepare()
|
||
|
|
||
|
const app = express()
|
||
|
|
||
|
app.use('/api', require('./api'))
|
||
|
app.use(nextRequestHandler)
|
||
|
|
||
|
// await promisify(app.listen)(3000)
|
||
|
|
||
|
app.listen(3000, err=>{
|
||
|
if(err) throw err
|
||
|
|
||
|
console.log('App listening on port 3000')
|
||
|
})
|
||
|
|
||
|
|
||
|
})().catch((ex) => {
|
||
|
console.error(ex.stack)
|
||
|
process.exit(1)
|
||
|
})
|