@nordsym/apiclaw 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/convex/http.ts +79 -0
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +1 -1
- package/dist/proxy.js.map +1 -1
- package/package.json +1 -1
- package/src/proxy.ts +1 -1
package/convex/http.ts
CHANGED
|
@@ -701,6 +701,85 @@ http.route({
|
|
|
701
701
|
handler: httpAction(async () => new Response(null, { headers: corsHeaders })),
|
|
702
702
|
});
|
|
703
703
|
|
|
704
|
+
// GitHub API proxy
|
|
705
|
+
http.route({
|
|
706
|
+
path: "/proxy/github",
|
|
707
|
+
method: "POST",
|
|
708
|
+
handler: httpAction(async (ctx, request) => {
|
|
709
|
+
// Validate session and log usage
|
|
710
|
+
const body = await request.json();
|
|
711
|
+
const action = body.action || "search_repos";
|
|
712
|
+
await validateAndLogProxyCall(ctx, request, "github", action);
|
|
713
|
+
|
|
714
|
+
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
|
|
715
|
+
if (!GITHUB_TOKEN) {
|
|
716
|
+
return jsonResponse({ error: "GitHub not configured" }, 500);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
try {
|
|
720
|
+
const { action, ...params } = body;
|
|
721
|
+
let url: string;
|
|
722
|
+
let method = "GET";
|
|
723
|
+
let fetchBody: string | undefined;
|
|
724
|
+
|
|
725
|
+
// Route based on action
|
|
726
|
+
switch (action) {
|
|
727
|
+
case "search_repos":
|
|
728
|
+
const { query, sort = "stars", limit = 10 } = params;
|
|
729
|
+
url = `https://api.github.com/search/repositories?q=${encodeURIComponent(query)}&sort=${sort}&per_page=${limit}`;
|
|
730
|
+
break;
|
|
731
|
+
|
|
732
|
+
case "get_repo":
|
|
733
|
+
const { owner, repo } = params;
|
|
734
|
+
url = `https://api.github.com/repos/${owner}/${repo}`;
|
|
735
|
+
break;
|
|
736
|
+
|
|
737
|
+
case "list_issues":
|
|
738
|
+
const { owner: issueOwner, repo: issueRepo, state = "open", limit: issueLimit = 10 } = params;
|
|
739
|
+
url = `https://api.github.com/repos/${issueOwner}/${issueRepo}/issues?state=${state}&per_page=${issueLimit}`;
|
|
740
|
+
break;
|
|
741
|
+
|
|
742
|
+
case "create_issue":
|
|
743
|
+
const { owner: createOwner, repo: createRepo, title, body: issueBody = "" } = params;
|
|
744
|
+
url = `https://api.github.com/repos/${createOwner}/${createRepo}/issues`;
|
|
745
|
+
method = "POST";
|
|
746
|
+
fetchBody = JSON.stringify({ title, body: issueBody });
|
|
747
|
+
break;
|
|
748
|
+
|
|
749
|
+
case "get_file":
|
|
750
|
+
const { owner: fileOwner, repo: fileRepo, path } = params;
|
|
751
|
+
url = `https://api.github.com/repos/${fileOwner}/${fileRepo}/contents/${path}`;
|
|
752
|
+
break;
|
|
753
|
+
|
|
754
|
+
default:
|
|
755
|
+
return jsonResponse({ error: `Unknown action: ${action}` }, 400);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
const response = await fetch(url, {
|
|
759
|
+
method,
|
|
760
|
+
headers: {
|
|
761
|
+
"Authorization": `Bearer ${GITHUB_TOKEN}`,
|
|
762
|
+
"Accept": "application/vnd.github+json",
|
|
763
|
+
"User-Agent": "APIClaw",
|
|
764
|
+
...(fetchBody ? { "Content-Type": "application/json" } : {}),
|
|
765
|
+
},
|
|
766
|
+
...(fetchBody ? { body: fetchBody } : {}),
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
const data = await response.json();
|
|
770
|
+
return jsonResponse(data, response.status);
|
|
771
|
+
} catch (e: any) {
|
|
772
|
+
return jsonResponse({ error: e.message }, 500);
|
|
773
|
+
}
|
|
774
|
+
}),
|
|
775
|
+
});
|
|
776
|
+
|
|
777
|
+
http.route({
|
|
778
|
+
path: "/proxy/github",
|
|
779
|
+
method: "OPTIONS",
|
|
780
|
+
handler: httpAction(async () => new Response(null, { headers: corsHeaders })),
|
|
781
|
+
});
|
|
782
|
+
|
|
704
783
|
// ==============================================
|
|
705
784
|
// WORKSPACE / MAGIC LINK ENDPOINTS
|
|
706
785
|
// ==============================================
|
package/dist/proxy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAe3E;AAED,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAe3E;AAED,eAAO,MAAM,eAAe,UAAkN,CAAC"}
|
package/dist/proxy.js
CHANGED
|
@@ -15,5 +15,5 @@ export async function callProxy(provider, params) {
|
|
|
15
15
|
}
|
|
16
16
|
return response.json();
|
|
17
17
|
}
|
|
18
|
-
export const PROXY_PROVIDERS = ["openrouter", "brave_search", "resend", "elevenlabs", "46elks", "twilio", "replicate", "firecrawl", "e2b", "groq", "deepgram", "serper", "mistral", "cohere", "together", "stability", "assemblyai"];
|
|
18
|
+
export const PROXY_PROVIDERS = ["openrouter", "brave_search", "resend", "elevenlabs", "46elks", "twilio", "replicate", "firecrawl", "e2b", "groq", "deepgram", "serper", "mistral", "cohere", "together", "stability", "assemblyai", "github"];
|
|
19
19
|
//# sourceMappingURL=proxy.js.map
|
package/dist/proxy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,UAAU,GAAG,kDAAkD,CAAC;AAEtE,MAAM,CAAC,KAAK,UAAU,SAAS,CAA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AAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;KAC7B,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC,CAAuB,CAAC;QAC/G,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,gBAAgB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/proxy.ts
CHANGED
|
@@ -21,4 +21,4 @@ export async function callProxy(provider: string, params: any): Promise<any> {
|
|
|
21
21
|
return response.json();
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export const PROXY_PROVIDERS = ["openrouter", "brave_search", "resend", "elevenlabs", "46elks", "twilio", "replicate", "firecrawl", "e2b", "groq", "deepgram", "serper", "mistral", "cohere", "together", "stability", "assemblyai"];
|
|
24
|
+
export const PROXY_PROVIDERS = ["openrouter", "brave_search", "resend", "elevenlabs", "46elks", "twilio", "replicate", "firecrawl", "e2b", "groq", "deepgram", "serper", "mistral", "cohere", "together", "stability", "assemblyai", "github"];
|