-
Notifications
You must be signed in to change notification settings - Fork 13
/
app.js
38 lines (33 loc) · 872 Bytes
/
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
const lambda = require("./index");
const express = require("express");
const app = express();
// app.get('/_healthz', function (req, res) {
// res.send('1');
// });
app.get("/thumbnail/:b64url", function(req, res) {
console.log("req.url",req.url);
try{
lambda.handler(
{
queryStringParameters: req.query,
pathParameters: {
url: req.url.replace("/thumbnail/", "").split('?')[0]
}
},
null,
async function(something, callback) {
console.log("callback: ", callback.statusCode, callback.headers);
res
.status(callback.statusCode)
.header(callback.headers)
.send(Buffer.from(callback.body, 'base64'))
}
)
} catch (error){
console.error(error);
res.status(400)
}
});
app.listen(5000, function() {
console.log("listening on :5000");
});