5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>✨ Y2K Vibes ✨</title>
7 <link rel="preconnect" href="https://fonts.googleapis.com">
8 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
9 <link href="https://fonts.googleapis.com/css2?family=Bubblegum+Sans&family=VT323&display=swap" rel="stylesheet">
10 <script src="https://cdn.twind.style" crossorigin></script>
11 <style>
1import { search } from "npm:google-sr";
2
3const API_KEY = Deno.env.get("SERP_API_KEY") ?? "";
4const endpoint = "https://serpapi.com/search.json";
5
6async function processResult(result) {
99 const parsedUrl = new URL(url);
100
101 // Handle both github.com URLs and API URLs
102 if (!parsedUrl.hostname.includes("github.com")) {
103 throw new Error("Not a GitHub URL");
132
133 try {
134 // GitHub API URL for repo contents
135 const apiUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${path}`;
136 console.log(`Fetching from: ${apiUrl}`);
137
138 const response = await fetch(apiUrl, {
139 headers: {
140 "Accept": "application/vnd.github.v3+json",
144
145 if (!response.ok) {
146 throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
147 }
148
165 }
166 } else if (item.content && item.encoding === "base64") {
167 // Some API responses include base64 encoded content
168 content = Buffer.from(item.content, "base64").toString("utf8");
169 } else {
379app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
380
381// Add your API routes here
382// app.get("/api/data", c => c.json({ hello: "world" }));
383
384// Unwrap and rethrow Hono errors as the original error
4export function App() {
5 const [projectUrl, setProjectUrl] = useState("");
6 const [apiToken, setApiToken] = useState("");
7 const [loading, setLoading] = useState(false);
8 const [message, setMessage] = useState("");
21 }
22
23 if (!apiToken.trim()) {
24 throw new Error("API Token is required");
25 }
26
28 method: "POST",
29 headers: {
30 "Authorization": `Bearer ${apiToken}`,
31 "Content-Type": "application/json",
32 },
69
70 <div>
71 <label htmlFor="apiToken" className="block text-sm font-medium text-gray-700 mb-1">
72 Val Town API Token (project read + write permissions)
73 </label>
74 <input
75 id="apiToken"
76 type="password"
77 value={apiToken}
78 onChange={(e) => setApiToken(e.target.value)}
79 placeholder="Enter your API token"
80 className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-purple-500"
81 />
20 }
21
22 const { apiKey, originalVals, projectName, username } = body;
23
24 console.log("Received redirect request:", {
28 });
29
30 if (!apiKey) {
31 return new Response(JSON.stringify({ error: "API key is required" }), {
32 status: 400,
33 headers: { "Content-Type": "application/json" },
49 }
50
51 const result = await redirectOriginalVals(apiKey, originalVals, projectName, username);
52
53 return new Response(JSON.stringify(result), {
2 let FARCASTER_USERNAME = "whatrocks";
3 let flings = await fetch(
4 `https://searchcaster.xyz/api/search?regex=%E2%8C%86&username=${FARCASTER_USERNAME}`,
5 ).then((res) => res.json());
6 let filteredCasts = flings.casts.filter((cast) => cast.body.data.text[0] === "⌆");
24 - Ensure the token has read/write access to _Contents_ for the repo
25 - Copy the access token and add that as the `GITHUB_TOKEN` env var in this val
261. Add a new [Val Town API token][] with read/write permissions. Add that token to the val's env vars as `VALTOWN_TOKEN`
271. Add a `VAL_SECRET` env var to the val. Use this secret to sign the webhook POST request to the `/push` endpoint. Use this endpoint to commit vals from Val Town to your GitHub repo.
28
68
69- `GITHUB_TOKEN`: Read/write GitHub personal access token for reading and writing repo contents
70- `VALTOWN_TOKEN`: ValTown API token (with read/write Vals permissions) for writing updates from GitHub
71- `GITHUB_WEBHOOK_SECRET`: secret for verifying webhooks from GitHub
72- `VAL_SECRET`: secret for verifying requests to the `/push` endpoint
98[github oauth app]: https://github.com/settings/developers
99[access token]: https://github.com/settings/tokens
100[val town api token]: https://www.val.town/settings/api
101[troubleshooting]: #troubleshooting
102
18
19 try {
20 const response = await fetch("/api/research", {
21 method: "POST",
22 headers: { "Content-Type": "application/json" },
86
87 <div className="footer">
88 <button onClick={() => window.open("/api/view-source", "_blank")} className="view-source">
89 View Source
90 </button>
9 background-color: #121212;
10 color: #e0e0e0;
11 background-image: url('/api/placeholder/1280/720');
12 background-size: cover;
13 background-position: center;
333}
334
335// Mock function to simulate AI response (in a real app, this would call an API)
336function getAIResponse(userMessage) {
337 return new Promise((resolve) => {
1{
2 "openapi": "3.0.0",
3 "info": {
4 "title": "Chat App API",
5 "version": "1.0.0",
6 "description": "Full OpenAPI documentation for the chat application backend"
7 },
8 "paths": {