1import * as elmPages from "./elm-pages-cli.mjs";
2import * as busboy from "busboy";
6export const handler = render;
10 * @param {import('aws-lambda').APIGatewayProxyEvent} event
11 * @param {any} context
13async function render(event, context) {
15 const renderResult = await elmPages.render(await reqToJson(event));
16 const { headers, statusCode } = renderResult;
18 if (renderResult.kind === "bytes") {
20 body: Buffer.from(renderResult.body).toString("base64"),
21 isBase64Encoded: true,
23 "Content-Type": ["application/octet-stream"],
24 "x-powered-by": ["elm-pages"],
29 } else if (renderResult.kind === "api-response") {
31 body: renderResult.body,
32 multiValueHeaders: headers,
34 isBase64Encoded: renderResult.isBase64Encoded,
38 body: renderResult.body,
40 "Content-Type": ["text/html"],
41 "x-powered-by": ["elm-pages"],
49 console.error(JSON.stringify(error, null, 2));
51 body: `<body><h1>Error</h1><pre>${JSON.stringify(error, null, 2)}</pre></body>`,
54 "Content-Type": ["text/html"],
55 "x-powered-by": ["elm-pages"],
62 * @param {import('aws-lambda').APIGatewayProxyEvent} req
63 * @returns {{method: string; rawUrl: string; body: string?; headers: Record<string, string>; multiPartFormData: unknown }}
65function reqToJson(req) {
67 requestTime: Math.round(new Date().getTime()),
68 method: req.httpMethod,
71 body: req.body || null,
72 multiPartFormData: null,
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list