Skip to content

Commit

Permalink
chore: update deno example
Browse files Browse the repository at this point in the history
  • Loading branch information
frytg committed Nov 14, 2024
1 parent dec83da commit f8803f5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions web/deno.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as BunnySDK from "https://esm.sh/@bunny.net/edgescript-sdk@0.11.2";
import { generate_github_chart } from "https://esm.sh/githubchart-rust@5.1.3/githubchart_rust_deno.js";
import { generate_github_chart } from "https://esm.sh/githubchart-rust@5.1.4/githubchart_rust_deno.js";

/**
* Executes a WASM binary and returns the response value
Expand All @@ -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, {
Expand Down

0 comments on commit f8803f5

Please sign in to comment.