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.
31 lines
692 B
JavaScript
31 lines
692 B
JavaScript
require('dotenv').config()
|
|
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()
|
|
const app = express()
|
|
app.listen = promisify(app.listen.bind(app))
|
|
|
|
;(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 app.listen(3000)
|
|
|
|
console.log('App listening on port 3000')
|
|
|
|
})().catch((ex) => {
|
|
console.error(ex.stack)
|
|
process.exit(1)
|
|
})
|