forked from ustaxcourt/ef-cms
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathswaggerLambda.js
36 lines (34 loc) · 964 Bytes
/
swaggerLambda.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
const { headerOverride } = require('../lambdaWrapper');
/**
* render the swagger html page
*
* @returns {object} the api gateway response object containing the statusCode, body, and headers
*/
exports.swaggerLambda = () => {
const body = `<html>
<body>
<head>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.24.2/swagger-ui.css">
</head>
<div id="swagger"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.24.2/swagger-ui-bundle.js"></script>
<script>
SwaggerUIBundle({
dom_id: '#swagger',
url: '/api/swagger.json',
supportedSubmitMethods: []
});
</script>
</body>
</html>`;
return {
body,
headers: {
...headerOverride,
'Content-Type': 'text/html',
'X-Frame-Options': 'DENY',
'X-XSS-Protection': '1; mode=block',
},
statusCode: '200',
};
};