mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-28 06:05:31 +03:00
Transform AWS event payload into event for DataSource.ServerRequest JSON.
This commit is contained in:
parent
a9ebd8559a
commit
35c5be1ee0
@ -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
|
||||
};
|
||||
}
|
||||
|
@ -252,6 +252,7 @@ async function start(options) {
|
||||
* @param {string} pathname
|
||||
* @param {((value: any) => any) | null | undefined} onOk
|
||||
* @param {((reason: any) => PromiseLike<never>) | 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 = () => {};
|
||||
|
@ -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; }) )>}
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user