-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
27 lines (24 loc) · 713 Bytes
/
server.js
File metadata and controls
27 lines (24 loc) · 713 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
require('dotenv').config();
const express = require('express');
const app = express();
app.use(express.json());
const { handler } = require('./lambda/src/index');
app.all('/', async (req, res) => {
// Transform the Express request object into an AWS Lambda API Gateway event
const event = {
httpMethod: req.method,
path: req.path,
headers: req.headers,
queryStringParameters: req.query,
body: JSON.stringify(req.body),
isBase64Encoded: false,
};
console.log(event);
const { headers, body, statusCode } = await handler(event);
res.set(headers);
res.status(statusCode).json(JSON.parse(body));
});
const port = 8080;
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});