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
1 changed file
with
5 additions
and
3 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import * as BunnySDK from "https://esm.sh/@bunny.net/[email protected]"; | ||
import { generate_github_chart } from "https://esm.sh/[email protected].3/githubchart_rust_deno.js"; | ||
import { generate_github_chart } from "https://esm.sh/[email protected].4/githubchart_rust_deno.js"; | ||
|
||
/** | ||
* Executes a WASM binary and returns the response value | ||
|
@@ -10,15 +10,17 @@ BunnySDK.net.http.serve(async (req: Request): Promise<Response> => { | |
try { | ||
// parse incoming request | ||
const url = new URL(req.url); | ||
const splittedUrl = url.pathname.split("/"); | ||
|
||
// extract username from path | ||
const username = url.pathname.split("/")[1]; | ||
const username = splittedUrl[1]; | ||
const color = splittedUrl[2] || "default"; | ||
|
||
// 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"); | ||
const chart = await generate_github_chart(username, color); | ||
|
||
// return response | ||
return new Response(chart, { | ||
|