OpenTowniesystem_prompt.txt2 matches
155* The main App component is rendered on the client.
156* No server-side-specific code should be included in the App.
157* Use fetch to communicate with the backend server portion.
158*/
159function App() {
178* Server-only code
179* Any code that is meant to run on the server should be included in the server function.
180* This can include endpoints that the client side component can send fetch requests to.
181*/
182export default async function server(request: Request): Promise<Response> {
OpenTownieindex1 match
2627try {
28const response = await fetch("/", {
29method: "POST",
30headers: { "authorization": "Bearer " + bearerToken },
OpenTowniegenerateCode1 match
2627export async function generateCodeAnthropic(messages: Message[]): Promise<ValResponse | null> {
28const system = await (await fetch(`${import.meta.url.split("/").slice(0, -1).join("/")}/system_prompt.txt`)).text();
2930const openai = new OpenAI({
ThumbMakermain.tsx1 match
394app.get('/main.js', serve(js, 'text/javascript'));
395396export default app.fetch;
azureDinosaurmain.tsx2 matches
1import { fetchFile, toBlobURL } from "https://esm.sh/@ffmpeg/util";
2import { FFmpeg } from "https://maxm-emeraldox.web.val.run/@ffmpeg/ffmpeg";
38wasmURL: `https://esm.sh/@ffmpeg/core@0.12.6/dist/umd/ffmpeg-core.wasm`,
9});
10console.log(FFmpeg, fetchFile, toBlobURL);
createWebsitemain.tsx4 matches
68e.preventDefault();
69try {
70const response = await fetch(`${API_BASE_URL}/login`, {
71method: 'POST',
72headers: { 'Content-Type': 'application/json' },
121122try {
123const response = await fetch(`${API_BASE_URL}/signup`, {
124method: 'POST',
125headers: { 'Content-Type': 'application/json' },
181182try {
183const response = await fetch(`${API_BASE_URL}/upload`, {
184method: 'POST',
185body: formData
215216try {
217const response = await fetch(`${API_BASE_URL}/chat`, {
218method: 'POST',
219headers: { 'Content-Type': 'application/json' },
sqliteAdminDashboardmain.tsx15 matches
1516useEffect(() => {
17fetchTables();
18}, []);
1920const fetchTables = async () => {
21try {
22const response = await fetch("/tables");
23const data = await response.json();
24setTables(data);
25} catch (err) {
26setError("Failed to fetch tables");
27}
28};
2930const fetchTableData = async (tableName) => {
31try {
32const dataResponse = await fetch(`/table/${tableName}`);
33const data = await dataResponse.json();
34setTableData(data);
3536const schemaResponse = await fetch(`/schema/${tableName}`);
37const schema = await schemaResponse.json();
38setTableSchema(schema);
46setNewRow(emptyRow);
47} catch (err) {
48setError(`Failed to fetch data for table ${tableName}`);
49}
50};
56const handleSave = async (index) => {
57try {
58const response = await fetch(`/update/${selectedTable}`, {
59method: "POST",
60headers: {
67}
68setEditingRow(null);
69await fetchTableData(selectedTable);
70} catch (err) {
71setError(`Failed to update row: ${err.message}`);
85const handleAddRow = async () => {
86try {
87const response = await fetch(`/insert/${selectedTable}`, {
88method: "POST",
89headers: {
95throw new Error("Failed to add new row");
96}
97await fetchTableData(selectedTable);
98// Reset newRow to empty values
99const emptyRow = Object.keys(newRow).reduce((acc, key) => {
109const handleDeleteTable = async () => {
110try {
111const response = await fetch(`/table/${selectedTable}`, {
112method: "DELETE",
113});
121setTableData([]);
122setTableSchema([]);
123await fetchTables();
124} catch (err) {
125setError(`Failed to delete table: ${err.message}`);
135<li
136key={table}
137onClick={() => fetchTableData(table)}
138className={selectedTable === table ? "active" : ""}
139>
competentOlivePeacockmain.tsx9 matches
5354useEffect(() => {
55fetchContent();
56}, []);
5758const fetchContent = async () => {
59try {
60const response = await fetch("/api/content");
61const data = await response.json();
62if (data.records) {
63setContent(data.records);
64} else {
65throw new Error("Failed to fetch content");
66}
67setLoading(false);
68} catch (error) {
69console.error("Error fetching content:", error);
70setLoading(false);
71}
99const analyzeContent = async (item: AirtableRecord) => {
100try {
101const response = await fetch("/api/analyze", {
102method: "POST",
103headers: {
265266try {
267const response = await fetch(airtableUrl, {
268headers: {
269"Authorization": `Bearer ${apiToken}`,
279return new Response(JSON.stringify(data), { headers });
280} catch (error) {
281console.error("Error fetching Airtable data:", error);
282return new Response(JSON.stringify({ error: "Error fetching data from Airtable" }), {
283status: 500,
284headers,
regexWordSearchPagemain.tsx4 matches
1516useEffect(() => {
17async function fetchWords() {
18try {
19const response = await fetch('https://raw.githubusercontent.com/dwyl/english-words/refs/heads/master/words.txt');
20if (!response.ok) throw new Error('Failed to fetch words');
21const text = await response.text();
22const wordList = text.split('\n')
38}
39}
40fetchWords();
41}, []);
42
githubParsermain.tsx23 matches
243244245async function fetchFileTypes(repoUrl) {
246const response = await fetch('/file-types', {
247method: 'POST',
248headers: { 'Content-Type': 'application/json' },
375try {
376console.log('Sending request to /parse endpoint...');
377const response = await fetch('/parse', {
378method: 'POST',
379headers: {
444try {
445const ignoredPatterns = parseIgnoredPatterns();
446const fileTypes = await fetchFileTypes(repoUrl);
447displayFileTypeSelector(fileTypes, ignoredPatterns);
448} catch (error) {
500}
501502console.log(`Fetching content for ${owner}/${repo}`);
503const content = await fetchRepositoryContent(owner, repo, branch, ignoredPatterns, selectedTypes);
504const tokenCounts = await countTokens(content);
505
587}
588589async function fetchRepositoryContent(owner, repo, specifiedBranch = null, ignoredPatterns, selectedTypes = null) {
590// First, try to get the default branch or use the specified branch
591const repoInfoUrl = `https://api.github.com/repos/${owner}/${repo}`;
592const repoInfoResponse = await fetch(repoInfoUrl, {
593headers: {
594'Authorization': `token ${Deno.env.get("GITHUB_API_KEY")}`,
601throw new Error(`Repository not found or not accessible: ${owner}/${repo}`);
602}
603throw new Error(`Failed to fetch repository info: ${repoInfoResponse.statusText}`);
604}
605608609const apiUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${defaultBranch}?recursive=1`;
610const response = await fetch(apiUrl, {
611headers: {
612'Authorization': `token ${Deno.env.get("GITHUB_API_KEY")}`,
617if (!response.ok) {
618if (response.status === 404) {
619throw new Error(`Failed to fetch repository content. The ${defaultBranch} branch might not exist.`);
620}
621throw new Error(`GitHub API request failed: ${response.statusText}`);
645for (const file of files) {
646try {
647const fileContent = await fetchFileContent(owner, repo, file.path, defaultBranch);
648content += `File: ${file.path}\n\n${fileContent}\n\n`;
649} catch (error) {
650console.error(`Failed to fetch content for ${file.path}: ${error.message}`);
651content += `File: ${file.path}\n\nError: Failed to fetch content\n\n`;
652}
653}
661}
662663async function fetchFileContent(owner, repo, path, branch) {
664const apiUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${path}`;
665const response = await fetch(apiUrl, {
666headers: {
667'Authorization': `token ${Deno.env.get("GITHUB_API_KEY")}`,
671672if (!response.ok) {
673throw new Error(`Failed to fetch file content: ${response.statusText}`);
674}
675792}
793794// Add new endpoint to handle file type fetching
795app.post("/file-types", async (c) => {
796try {
822async function getRepositoryFileTypes(owner, repo, specifiedBranch = null) {
823const repoInfoUrl = `https://api.github.com/repos/${owner}/${repo}`;
824const repoInfoResponse = await fetch(repoInfoUrl, {
825headers: {
826'Authorization': `token ${Deno.env.get("GITHUB_API_KEY")}`,
830
831if (!repoInfoResponse.ok) {
832throw new Error(`Failed to fetch repository info: ${repoInfoResponse.statusText}`);
833}
834
837
838const apiUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${defaultBranch}?recursive=1`;
839const response = await fetch(apiUrl, {
840headers: {
841'Authorization': `token ${Deno.env.get("GITHUB_API_KEY")}`,
863}
864865// Export app.fetch for Val Town, otherwise export app — this is only for hono apps
866export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;
867