diff --git a/examples/pokedex/functions/render/index.js b/examples/pokedex/functions/render/index.js index abe99ccd..f9eb7ed4 100644 --- a/examples/pokedex/functions/render/index.js +++ b/examples/pokedex/functions/render/index.js @@ -39,7 +39,7 @@ async function render(event, context) { require(compiledElmPath), mode, event.path, - event, + reqToJson(event), addWatcher ); @@ -76,3 +76,24 @@ async function render(event, context) { }; } } + +// * @param {import('aws-lambda').APIGatewayProxyEvent} event + +/** + * @param {import('aws-lambda').APIGatewayProxyEvent} req + * @returns {{ method: string; hostname: string; query: string; headers: Object; host: string; pathname: string; port: string; protocol: string; rawUrl: string; }} + */ +function reqToJson(req) { + return { + method: req.httpMethod, + hostname: "TODO", + // query: req.queryStringParameters, //url.search ? url.search.substring(1) : "", + query: "", //url.search ? url.search.substring(1) : "", + headers: req.headers, + host: url.host, + pathname: req.path, + port: null, // TODO + protocol: "https", // TODO + rawUrl: "", // TODO + }; +} diff --git a/generator/src/dev-server.js b/generator/src/dev-server.js index 24e9d20d..cfc5b8ac 100644 --- a/generator/src/dev-server.js +++ b/generator/src/dev-server.js @@ -252,6 +252,7 @@ async function start(options) { * @param {string} pathname * @param {((value: any) => any) | null | undefined} onOk * @param {((reason: any) => PromiseLike) | null | undefined} onErr + * @param {{ method: string; hostname: string; query: string; headers: Object; host: string; pathname: string; port: string; protocol: string; rawUrl: string; }} serverRequest */ function runRenderThread(serverRequest, pathname, onOk, onErr) { let cleanUpThread = () => {}; diff --git a/generator/src/render.js b/generator/src/render.js index bc3581bf..874bbea7 100755 --- a/generator/src/render.js +++ b/generator/src/render.js @@ -24,7 +24,7 @@ module.exports = * @param {string} basePath * @param {Object} elmModule * @param {string} path - * @param {import('aws-lambda').APIGatewayProxyEvent} request + * @param {{ method: string; hostname: string; query: string; headers: Object; host: string; pathname: string; port: string; protocol: string; rawUrl: string; }} request * @param {(pattern: string) => void} addDataSourceWatcher * @returns */ @@ -59,7 +59,7 @@ module.exports = * @param {Object} elmModule * @param {string} pagePath * @param {string} mode - * @param {import('aws-lambda').APIGatewayProxyEvent} request + * @param {{ method: string; hostname: string; query: string; headers: Object; host: string; pathname: string; port: string; protocol: string; rawUrl: string; }} request * @param {(pattern: string) => void} addDataSourceWatcher * @returns {Promise<({is404: boolean} & ( { kind: 'json'; contentJson: string} | { kind: 'html'; htmlString: string } | { kind: 'api-response'; body: string; }) )>} */