-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
62 lines (51 loc) · 1.47 KB
/
app.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
60
61
62
const express = require('express');
const path = require('path');
const https = require('https');
const fs = require('fs');
const app = express();
const port = 3000;
const serverOptions = {
key: fs.readFileSync('../../cert/localhost.key'),
cert: fs.readFileSync('../../cert/localhost.crt')
};
/*
* This server would check the inputs of the user and request the API
* and forward the results
*
* At the moment i just return a text based on the inputs of the user to
* test the Office Addin prototype
*/
app.get('/', (req, res) => {
let email_type = req.query.email_type;
let gender = req.query.gender;
let name = req.query.name;
let result = '';
result += 'Hallo';
if ((gender != undefined) && (name != undefined)) {
result += ' ' + gender + ' ' + name + ',\n';
} else {
result += ',\n';
}
switch (email_type) {
case 'meeting_request' :
result += 'Es handelt sich um eine Terminanfrage';
break;
case 'status_update' :
result += 'Es handelt sich um ein Status Update';
break;
case 'product_offer' :
result += 'Es handelt sich um eine Produkt Angebot';
break;
default:
break;
}
res.set('Access-Control-Allow-Origin', '*')
res.send(result);
})
app.get('/taskpane.html', function(req, res) {
res.sendFile(path.join(__dirname, '/taskpane.html'));
});
const server = https.createServer(serverOptions, app);
server.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})