-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8d8d86
commit 8ebfbca
Showing
8 changed files
with
52 additions
and
53 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
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 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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import { Buffer } from 'buffer'; | ||
|
||
export const base64Handler = async ({ params }) => { | ||
// Decode text like "Hello%20world" into "Hello world" | ||
let input = decodeURIComponent(params.text) | ||
export const base64Handler = async ({ params }: any) => { | ||
// Decode text like "Hello%20world" into "Hello world" | ||
let input = decodeURIComponent(params.text) | ||
|
||
// Construct a buffer from our input | ||
let buffer = Buffer.from(input, "utf8") | ||
// Construct a buffer from our input | ||
let buffer = Buffer.from(input, "utf8") | ||
|
||
// Serialise the buffer into a base64 string | ||
let base64 = buffer.toString("base64") | ||
// Serialise the buffer into a base64 string | ||
let base64 = buffer.toString("base64") | ||
|
||
const backendApi = 'https://6wkf624dt4.execute-api.us-east-1.amazonaws.com/prod/'; | ||
const response = await fetch(backendApi) | ||
const data = await response.json() | ||
const backendApi = 'https://6wkf624dt4.execute-api.us-east-1.amazonaws.com/prod/'; | ||
const response = await fetch(backendApi) | ||
const data = await response.json() | ||
|
||
// Return the HTML with the string to the client | ||
return new Response(` | ||
// Return the HTML with the string to the client | ||
return new Response(` | ||
<p>Base64 encoding: <code>${base64}</code></p> | ||
<p>${JSON.stringify(data, null, 2)}</p> | ||
`, { | ||
headers: { | ||
"Content-Type": "text/html" | ||
} | ||
}) | ||
headers: { | ||
"Content-Type": "text/html" | ||
} | ||
}) | ||
}; |
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 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 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 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 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