Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
branches:
- main
paths:
- "worker/**"
- "web/**"
- "src/**"
- "wrangler.jsonc"
Expand Down
2 changes: 1 addition & 1 deletion hk.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local linters = new Mapping<String, Step> {
stage = "*"
}
["tsc"] {
glob = List("src/**/*.ts", "worker/**/*.ts")
glob = List("src/**/*.ts")
check = "bunx tsc --noEmit"
batch = true
}
Expand Down
47 changes: 3 additions & 44 deletions scripts/github-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
/**
* GitHub Token Manager Helper for GitHub Actions
*
* This script fetches a GitHub token from the token manager API
* and can optionally record usage for rate limit tracking.
* This script fetches a GitHub token from the token manager API.
*
* Usage in GitHub Actions:
*
Expand All @@ -25,7 +24,6 @@

import https from "https";
import http from "http";
import fs from "fs";

async function makeRequest(url, options = {}) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -69,45 +67,6 @@ async function makeRequest(url, options = {}) {
});
}

async function recordUsage(baseUrl, secret, tokenId, endpoint, rateLimitInfo) {
const usageUrl = `${baseUrl}/api/token/usage`;

return new Promise((resolve, reject) => {
const urlObj = new URL(usageUrl);
const client = urlObj.protocol === "https:" ? https : http;

const payload = JSON.stringify({
token_id: tokenId,
endpoint,
remaining_requests: rateLimitInfo?.remaining,
reset_at: rateLimitInfo?.reset
? new Date(rateLimitInfo.reset * 1000).toISOString()
: undefined,
});

const req = client.request(
usageUrl,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${secret}`,
"Content-Length": Buffer.byteLength(payload),
},
},
(res) => {
let data = "";
res.on("data", (chunk) => (data += chunk));
res.on("end", () => resolve({ status: res.statusCode, data }));
},
);

req.on("error", reject);
req.write(payload);
req.end();
});
}

async function markRateLimited(baseUrl, secret, tokenId, resetTime) {
const rateLimitUrl = `${baseUrl}/api/token/rate-limit`;

Expand Down Expand Up @@ -212,7 +171,7 @@ async function main() {
console.error(` Total tokens: ${response.data.total}`);
} else {
console.error(
"❌ Unknown action. Available actions: get-token, record-usage, mark-rate-limited, stats",
"❌ Unknown action. Available actions: get-token, mark-rate-limited, stats",
);
process.exit(1);
}
Expand All @@ -227,4 +186,4 @@ if (import.meta.url === `file://${process.argv[1]}`) {
main();
}

export { makeRequest, recordUsage, markRateLimited };
export { makeRequest, markRateLimited };
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["src/**/*", "worker/**/*"],
"include": ["src/**/*"],
"exclude": ["web", "node_modules", "dist", "scripts"]
}
32 changes: 0 additions & 32 deletions web/wrangler.jsonc

This file was deleted.

113 changes: 0 additions & 113 deletions worker/index.ts

This file was deleted.

Loading