-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
executable file
·33 lines (26 loc) · 879 Bytes
/
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
import http from 'http';
import express from 'express';
import cors from 'cors';
import bodyParser from 'body-parser';
import { sslCheckResponse, slackAuth } from './middleware';
import api from './api';
var app = express();
app.server = http.createServer(app);
app.use(function(req, res, next) {
// Set permissive CORS header - this allows this server to be used as
// an API server
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Cache-Control', 'no-cache');
next();
});
// parse application/x-www-form-urlencoded and json
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
// use middleware
app.use(sslCheckResponse, slackAuth);
// enable api
app.use('/', api());
// start app
app.server.listen(process.env.PORT || 8080);
console.log(`Started on port ${app.server.address().port}`);
export default app;