forked from akerl/githubchart
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
6 changed files
with
57 additions
and
2 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 |
---|---|---|
|
@@ -2,3 +2,4 @@ target/ | |
.DS_Store | ||
*.svg | ||
!assets/*.svg | ||
pkg/ |
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,5 +1,9 @@ | ||
# Changelog | ||
|
||
## 5.1.3 / 2024-11-13 | ||
|
||
- feat: add Deno build to WASM | ||
|
||
## 5.1.0 / 2024-11-13 | ||
|
||
- feat: add WASM build | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as BunnySDK from "https://esm.sh/@bunny.net/[email protected]"; | ||
import { generate_github_chart } from "https://esm.sh/[email protected]/githubchart_rust_deno.js"; | ||
|
||
/** | ||
* Executes a WASM binary and returns the response value | ||
* @param {Request} request - The Fetch API Request object. | ||
* @return {Response} The HTTP response or string. | ||
*/ | ||
BunnySDK.net.http.serve(async (req: Request): Promise<Response> => { | ||
try { | ||
// parse incoming request | ||
const url = new URL(req.url); | ||
|
||
// extract username from path | ||
const username = url.pathname.split("/")[1]; | ||
|
||
// check if username is provided | ||
if (!username) return new Response("No username provided", { status: 400 }); | ||
|
||
// generate chart | ||
const chart = await generate_github_chart(username, "default"); | ||
|
||
// return response | ||
return new Response(chart, { | ||
headers: { | ||
"Content-Type": "image/svg+xml", | ||
"Cache-Control": "max-age=300", | ||
"x-generated-by": "githubchart-rust", | ||
"x-username": username, | ||
}, | ||
}); | ||
} catch (error) { | ||
console.log(req.method, req.url, error); | ||
return new Response("Internal Server Error", { status: 500 }); | ||
} | ||
}); |