-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (33 loc) · 1.03 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import express from 'express';
import bodyParser from 'body-parser';
import request from 'request';
import cors from 'cors';
const app = express();
let facebookPageToken = process.env.facebookPageToken;
app.set('port', (process.env.PORT || 5000));
const whitelist = ['http://localhost:3000', 'https://government-client.herokuapp.com', undefined];
const corsOptions = {
origin: function (origin, callback) {
if (whitelist.indexOf(origin) !== -1) {
callback(null, true)
} else {
callback(new Error('Not allowed by CORS'))
}
}
}
app.use(cors(corsOptions));
// Process application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({extended: false}))
// Process application/json
app.use(bodyParser.json())
// Index route
app.get('/', function (req, res) {
res.send('Hello world, I am a chat bot')
})
// Spin up the server
app.listen(app.get('port'), function() {
console.log(facebookPageToken);
console.log('running on port', app.get('port'))
})
require('./chatLogic.js')(app);
require('./browserActions.js')(app);