generated from kaskadi/template-kaskadi-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserve.js
34 lines (33 loc) · 1.02 KB
/
serve.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
// force deploy
module.exports.handler = async (event) => {
// retrieve host from query string if defined (meaning we are reaching this endpoint from a test environment)
const requestHost = event.queryStringParameters ? event.queryStringParameters.host : undefined
const host = requestHost ? `http://${requestHost}` : process.env.CFD_PUBLIC_DOMAIN
return {
statusCode: 200,
headers: {
'content-type': 'text/html'
},
body: getIndex(host)
}
}
function getIndex (host) {
return `<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Kaskadi app</title>
<link rel="icon" type="image/png" href="${host}/imgs/icons/favicon.png">
<script type="module" src="${host}/modules/@kaskadi/kaskadi-apps/kaskadi-app.js"></script>
<style>
html, body {
margin: 0;
padding: 0;
font-family: sans-serif;
font-size: 16px;
}
</style>
</head>
<body>
<kaskadi-app appVersion="${process.env.APP_VERSION}"></kaskadi-app>
</body>`
}