Skip to content

Commit

Permalink
Add leech handlng (#17)
Browse files Browse the repository at this point in the history
Co-authored-by: Jon Breen <[email protected]>
  • Loading branch information
cultpodcasts and cultpodcasts committed Mar 29, 2024
1 parent 08365f1 commit 8061196
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface Env {
Content: R2Bucket;
Data: R2Bucket;
Analytics: AnalyticsEngineDataset;
DB: D1Database;
apikey: string;
Expand Down Expand Up @@ -67,8 +68,15 @@ export default {
}
}
let isLeech: boolean = false;
if (city == "Wimbledon") {
isLeech = true;

const object = await env.Content.get("leeches");

if (object != null) {
var leaches: string[] = await object.json();

if (leaches.indexOf(ipAddress) > 0) {
isLeech = true;
}
}

if (!isLeech) {
Expand Down
6 changes: 4 additions & 2 deletions wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ main = "src/index.ts"
compatibility_date = "2023-09-04"

[[r2_buckets]]
binding = "Content"
bucket_name = "content"
r2_buckets = [
{ binding = "Content", bucket_name = "content", preview_bucket_name = "" },
{ binding = "Data", bucket_name = "data", preview_bucket_name = "" }
]

[[d1_databases]]
binding = "DB"
Expand Down

0 comments on commit 8061196

Please sign in to comment.