-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprogram.js
More file actions
45 lines (34 loc) · 1.21 KB
/
program.js
File metadata and controls
45 lines (34 loc) · 1.21 KB
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
const express = require('express')
const bodyParser = require('body-parser');
const SlackClient = require("./src/services/slackService");
const MicrosoftTeamsClient = require('./src/services/microsoftTeamsService');
const app = express()
app.use(bodyParser.json());
const port = 3000
app.post('/teams', function (req, res) {
try {
const title = req.body.title;
const message = req.body.message;
const token = req.headers['x-token-auth'];
console.log(token);
let client = new MicrosoftTeamsClient();
var send = client.enviaNotificacaoParaMicrosoftTeams(token, title, message)
res.json(send);
} catch (err) {
res.status(500).send(err.message);
}
})
app.post('/slack', async function (req, res) {
try {
const channelId = req.body.channelId;
const message = req.body.message;
let slackNotification = new SlackClient();
var send = await slackNotification.enviaNotificacaoParaSlack(channelId, message);
res.json(send);
} catch (err) {
res.status(500).send(err.message);
}
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})