-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstandup.js
59 lines (45 loc) · 1.57 KB
/
standup.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
if (process.env.NODE_ENV !== 'production') {
const dotEnv = require('dotenv');//Configure environmental variables
const result = dotEnv.config();
if (result.error) {
throw result.error
}
}
const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const appBootstrap = require("./src/main");
const debug = require("debug")("onaautostandup:index");
const api = require('./src/routes/api');
const kue = require("kue");
const kueUiExpress = require('kue-ui-express');
const app = express();
const rawBodyBuffer = (req, res, buf, encoding) => {
if (buf && buf.length) {
req.rawBody = buf.toString(encoding || 'utf8');
}
};
app.use(cors());
app.use(bodyParser.urlencoded({ verify: rawBodyBuffer, extended: true }));
app.use(bodyParser.json({ verify: rawBodyBuffer }));
// Error handling middleware
app.use(function (err, req, res, next) {
console.log(err.stack);
res.status(500).send({ error: err.message });
debug("App Error description: " + err)
});
app.use(process.env.APP_API_BASE, api);
app.get('/', (req, res) => {
res.send('<h2>AutoStandup app is up and running</h2> <p>Login to your' +
' slack account and start submitting standups.</p>');
});
appBootstrap.main();
app.listen(process.env.APP_API_PORT || 8008, function () {
console.log("[+] app listening for requests")
});
/**
* Configure and mount kue express dashboard {@link https://github.com/stonecircle/kue-ui-express }
kueUiExpress(app, '/kue/', '/kue-api');
app.use('/kue-api/', kue.app);
kue.app.listen(8007);
*/