Skip to content

Commit

Permalink
fix: update the deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
sshivaditya committed Jan 3, 2025
1 parent d038a0b commit 7766a20
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@v4
- name: Write secrets to wrangler.toml
run: |
sed -i 's/VOYAGE_API_KEY = ""/VOYAGE_API_KEY = "TEST"/g' wrangler.toml
sed -i 's/VOYAGE_API_KEY = ""/VOYAGE_API_KEY = "'${{ secrets.VOYAGE_API_KEY }}'"/g' wrangler.toml
sed -i 's/SUPABASE_URL = ""/SUPABASE_URL = "'${{ secrets.SUPABASE_URL }}'"/g' wrangler.toml
sed -i 's/SUPABASE_ANON_KEY = ""/SUPABASE_ANON_KEY = "'${{ secrets.SUPABASE_ANON_KEY }}'"/g' wrangler.toml
env:
Expand Down
69 changes: 33 additions & 36 deletions functions/issue-scraper.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,43 @@
import { Context } from "./types";

export const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET",
"Access-Control-Allow-Headers": "Content-Type",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET",
"Access-Control-Allow-Headers": "Content-Type",
};

export async function onRequest(ctx: Context): Promise<Response> {
const { request, env } = ctx;
console.log("Request received:", request.method, request.url);
console.log("Environment", env);
const url = new URL(request.url);
const { request, env } = ctx;
console.log("Request received:", request.method, request.url);
console.log("Environment", env);
const url = new URL(request.url);

try {
switch (request.method) {

case "GET":
if (url.searchParams.has("key")) {
const key = url.searchParams.get("key") as string;
return new Response("GET request with key: " + key + JSON.stringify(env), {
headers: corsHeaders,
status: 200,
});
}
return new Response("GET request", {
headers: corsHeaders,
status: 200,
});

default:
return new Response("Method Not Allowed", {
headers: corsHeaders,
status: 405,
});
}
} catch (error) {
console.error("Error processing request:", error);
return new Response("Internal Server Error", {
try {
switch (request.method) {
case "GET":
if (url.searchParams.has("key")) {
const key = url.searchParams.get("key") as string;
return new Response("GET request with key: " + key + JSON.stringify(env), {
headers: corsHeaders,
status: 500,
status: 200,
});
}
return new Response("GET request", {
headers: corsHeaders,
status: 200,
});
}


}
default:
return new Response("Method Not Allowed", {
headers: corsHeaders,
status: 405,
});
}
} catch (error) {
console.error("Error processing request:", error);
return new Response("Internal Server Error", {
headers: corsHeaders,
status: 500,
});
}
}

0 comments on commit 7766a20

Please sign in to comment.