Created
April 25, 2018 12:57
-
-
Save gladchinda/15e797675719f307e32a457b91c1a509 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const cors = require('cors'); | |
const next = require('next'); | |
const Pusher = require('pusher'); | |
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const dotenv = require('dotenv').config(); | |
const sentiment = require('sentiment'); | |
const dev = process.env.NODE_ENV !== 'production'; | |
const port = process.env.PORT || 3000; | |
const app = next({ dev }); | |
const handler = app.getRequestHandler(); | |
const pusher = new Pusher({ | |
appId: process.env.PUSHER_APP_ID, | |
key: process.env.PUSHER_APP_KEY, | |
secret: process.env.PUSHER_APP_SECRET, | |
cluster: process.env.PUSHER_APP_CLUSTER, | |
encrypted: true | |
}); | |
app.prepare() | |
.then(() => { | |
const server = express(); | |
server.use(cors()); | |
server.use(bodyParser.json()); | |
server.use(bodyParser.urlencoded({ extended: true })); | |
server.get('*', (req, res) => { | |
return handler(req, res); | |
}); | |
server.listen(port, err => { | |
if (err) throw err; | |
console.log(`> Ready on http://localhost:${port}`); | |
}); | |
}) | |
.catch(ex => { | |
console.error(ex.stack); | |
process.exit(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment