-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdbotindex.js
More file actions
30 lines (23 loc) · 741 Bytes
/
dbotindex.js
File metadata and controls
30 lines (23 loc) · 741 Bytes
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
'use strict';
var express = require('express');
var bodyParser = require('body-parser');
var config = require('./app/config');
var hellobot = require('./app/hellobot');
var dicebot = require('./app/dicebot');
var app = express();
var port = config.PORT || 3015;
// body parser middleware
app.use(bodyParser.urlencoded({ extended: true }));
// test route
app.get('/', function (req, res) { res.status(200).send('Hello world!'); });
app.post('/hello', hellobot);
app.post('/roll', dicebot.handlePost);
// error handler
app.use(function (err, req, res, next) {
console.error(err.stack);
res.status(400).send(err.message);
});
app.listen(port, function () {
console.log('Slack bot listening on port ' + port);
});
module.exports = app;