-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update begin adapter to new app-utils format
- Loading branch information
Showing
5 changed files
with
70 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
|
||
const url = require('url'); | ||
const app = require('@architect/shared/app.js'); | ||
|
||
exports.handler = async (event) => { | ||
|
||
const { | ||
rawPath: path, | ||
httpMethod, | ||
headers, | ||
queryStringParameters | ||
// body, // TODO pass this to renderer | ||
// isBase64Encoded // TODO is this useful? | ||
} = event; | ||
|
||
const query = new url.URLSearchParams(); | ||
for (const k in queryStringParameters) { | ||
const value = queryStringParameters[k]; | ||
value.split(', ').forEach((v) => { | ||
query.append(k, v); | ||
}); | ||
} | ||
|
||
const rendered = await app.render({ | ||
host: null, // TODO | ||
method: httpMethod, | ||
headers, | ||
path, | ||
query | ||
}); | ||
|
||
if (rendered) { | ||
return { | ||
isBase64Encoded: false, | ||
statusCode: rendered.status, | ||
headers: rendered.headers, | ||
body: rendered.body | ||
}; | ||
} | ||
|
||
return { | ||
statusCode: 404, | ||
body: 'Not found' | ||
}; | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.