-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
51 lines (41 loc) · 1.3 KB
/
server.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
var http = require("http");
var fs = require("fs");
var https = require("https");
var bodyParser = require('body-parser');
var express = require('express');
var app = express();
var lambda = require('./src/lambda/lambda');
var logger = function(req, res, next) {
console.log(req.originalUrl);
next(); // Passing the request to the next handler in the stack.
}
app.use(bodyParser.json());
app.use(logger);
app.use(express.static(__dirname + "/localBuild"));
//app.use(express.static(__dirname + "/src/web"));
app.use('/github-outlook365addins', express.static(__dirname + "/localBuild"));
app.get("/test.html", function(req, res){
res.redirect("directory.html");
})
app.post("/lambda", function(req, res){
var context = {
done: function (err, result) {
res.json(result);
}
};
console.log("lambda");
console.log(req.body);
lambda.handler(req.body, context);
});
var sslOptions = {
key: fs.readFileSync('ssl/localhost.key'),
cert: fs.readFileSync('ssl/localhost.crt'),
ca: fs.readFileSync('ssl/ca.crt'),
requestCert: true,
rejectUnauthorized: false
};
var httpServer = http.createServer(app);
httpServer = https.createServer(sslOptions, app);
var port = process.env.PORT || 8080;
console.log("starting on " + port);
httpServer.listen(port);