42</h2>
43<ol>
44<li>Login with your Val Town API token (with projects:read, projects:write, user:read permissions)</li>
45<li>Select a project to work on</li>
46<li>Chat with Claude about your code</li>
79</div>
80<h3>Cost Tracking</h3>
81<p>See estimated API usage costs for each interaction</p>
82</div>
83</section>
92<ul>
93<li>React frontend with TypeScript</li>
94<li>Hono API server backend</li>
95<li>Web Audio API for sound notifications</li>
96<li>AI SDK for Claude integration</li>
97</ul>
98<p>
99The application proxies requests to the Anthropic API and Val Town API, allowing Claude to view and edit your
100project files directly.
101</p>
TownieChatRoute.tsx2 matches
63refetch: () => void;
64}) {
65const { token, anthropicApiKey } = useAuth();
66const [images, setImages] = useState<(string|null)[]>([]);
67const [selectedFiles, setSelectedFiles] = useState<string[]>([]);
81project,
82branchId,
83anthropicApiKey,
84bearerToken: token,
85selectedFiles,
blob_adminmain.tsx6 matches
1415// Public route without authentication
16app.get("/api/public/:id", async (c) => {
17const key = `__public/${c.req.param("id")}`;
18const { blob } = await import("https://esm.town/v/std/blob");
132};
133134app.get("/api/blobs", checkAuth, async (c) => {
135const prefix = c.req.query("prefix") || "";
136const limit = parseInt(c.req.query("limit") || "20", 10);
141});
142143app.get("/api/blob", checkAuth, async (c) => {
144const key = c.req.query("key");
145if (!key) return c.text("Missing key parameter", 400);
149});
150151app.put("/api/blob", checkAuth, async (c) => {
152const key = c.req.query("key");
153if (!key) return c.text("Missing key parameter", 400);
158});
159160app.delete("/api/blob", checkAuth, async (c) => {
161const key = c.req.query("key");
162if (!key) return c.text("Missing key parameter", 400);
166});
167168app.post("/api/blob", checkAuth, async (c) => {
169const { file, key } = await c.req.parseBody();
170if (!file || !key) return c.text("Missing file or key", 400);
blob_adminapp.tsx19 matches
70const menuRef = useRef(null);
71const isPublic = blob.key.startsWith("__public/");
72const publicUrl = isPublic ? `${window.location.origin}/api/public/${encodeURIComponent(blob.key.slice(9))}` : null;
7374useEffect(() => {
234setLoading(true);
235try {
236const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
237const data = await response.json();
238setBlobs(data);
261setBlobContentLoading(true);
262try {
263const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
264const content = await response.text();
265setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
275const handleSave = async () => {
276try {
277await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
278method: "PUT",
279body: editContent,
287const handleDelete = async (key) => {
288try {
289await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
290setBlobs(blobs.filter(b => b.key !== key));
291if (selectedBlob && selectedBlob.key === key) {
304const key = `${searchPrefix}${file.name}`;
305formData.append("key", encodeKey(key));
306await fetch("/api/blob", { method: "POST", body: formData });
307const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
308setBlobs([newBlob, ...blobs]);
326try {
327const fullKey = `${searchPrefix}${key}`;
328await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
329method: "PUT",
330body: "",
341const handleDownload = async (key) => {
342try {
343const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
344const blob = await response.blob();
345const url = window.URL.createObjectURL(blob);
360if (newKey && newKey !== oldKey) {
361try {
362const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
363const content = await response.blob();
364await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
365method: "PUT",
366body: content,
367});
368await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
369setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
370if (selectedBlob && selectedBlob.key === oldKey) {
380const newKey = `__public/${key}`;
381try {
382const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
383const content = await response.blob();
384await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
385method: "PUT",
386body: content,
387});
388await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
389setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
390if (selectedBlob && selectedBlob.key === key) {
399const newKey = key.slice(9); // Remove "__public/" prefix
400try {
401const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
402const content = await response.blob();
403await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
404method: "PUT",
405body: content,
406});
407await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
408setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
409if (selectedBlob && selectedBlob.key === key) {
554onClick={() =>
555copyToClipboard(
556`${window.location.origin}/api/public/${encodeURIComponent(selectedBlob.key.slice(9))}`,
557)}
558className="text-blue-400 hover:text-blue-300 text-sm"
577>
578<img
579src={`/api/blob?key=${encodeKey(selectedBlob.key)}`}
580alt="Blob content"
581className="max-w-full h-auto"
blob_adminmain.tsx6 matches
1415// Public route without authentication
16app.get("/api/public/:id", async (c) => {
17const key = `__public/${c.req.param("id")}`;
18const { blob } = await import("https://esm.town/v/std/blob");
132};
133134app.get("/api/blobs", checkAuth, async (c) => {
135const prefix = c.req.query("prefix") || "";
136const limit = parseInt(c.req.query("limit") || "20", 10);
141});
142143app.get("/api/blob", checkAuth, async (c) => {
144const key = c.req.query("key");
145if (!key) return c.text("Missing key parameter", 400);
149});
150151app.put("/api/blob", checkAuth, async (c) => {
152const key = c.req.query("key");
153if (!key) return c.text("Missing key parameter", 400);
158});
159160app.delete("/api/blob", checkAuth, async (c) => {
161const key = c.req.query("key");
162if (!key) return c.text("Missing key parameter", 400);
166});
167168app.post("/api/blob", checkAuth, async (c) => {
169const { file, key } = await c.req.parseBody();
170if (!file || !key) return c.text("Missing file or key", 400);
blob_adminapp.tsx19 matches
70const menuRef = useRef(null);
71const isPublic = blob.key.startsWith("__public/");
72const publicUrl = isPublic ? `${window.location.origin}/api/public/${encodeURIComponent(blob.key.slice(9))}` : null;
7374useEffect(() => {
234setLoading(true);
235try {
236const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
237const data = await response.json();
238setBlobs(data);
261setBlobContentLoading(true);
262try {
263const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
264const content = await response.text();
265setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
275const handleSave = async () => {
276try {
277await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
278method: "PUT",
279body: editContent,
287const handleDelete = async (key) => {
288try {
289await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
290setBlobs(blobs.filter(b => b.key !== key));
291if (selectedBlob && selectedBlob.key === key) {
304const key = `${searchPrefix}${file.name}`;
305formData.append("key", encodeKey(key));
306await fetch("/api/blob", { method: "POST", body: formData });
307const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
308setBlobs([newBlob, ...blobs]);
326try {
327const fullKey = `${searchPrefix}${key}`;
328await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
329method: "PUT",
330body: "",
341const handleDownload = async (key) => {
342try {
343const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
344const blob = await response.blob();
345const url = window.URL.createObjectURL(blob);
360if (newKey && newKey !== oldKey) {
361try {
362const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
363const content = await response.blob();
364await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
365method: "PUT",
366body: content,
367});
368await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
369setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
370if (selectedBlob && selectedBlob.key === oldKey) {
380const newKey = `__public/${key}`;
381try {
382const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
383const content = await response.blob();
384await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
385method: "PUT",
386body: content,
387});
388await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
389setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
390if (selectedBlob && selectedBlob.key === key) {
399const newKey = key.slice(9); // Remove "__public/" prefix
400try {
401const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
402const content = await response.blob();
403await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
404method: "PUT",
405body: content,
406});
407await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
408setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
409if (selectedBlob && selectedBlob.key === key) {
554onClick={() =>
555copyToClipboard(
556`${window.location.origin}/api/public/${encodeURIComponent(selectedBlob.key.slice(9))}`,
557)}
558className="text-blue-400 hover:text-blue-300 text-sm"
577>
578<img
579src={`/api/blob?key=${encodeKey(selectedBlob.key)}`}
580alt="Blob content"
581className="max-w-full h-auto"
79801. **Create a Slack App**:
81- Go to [Slack API Apps](https://api.slack.com/apps) → Create New App → From scratch
82- Name your app and select your workspace
83- Click "Create App"
32};
3334// Types for Slack API
35type SlackMessage = {
36blocks: any[];
219220// Get PR details
221const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`;
222223let response;
241return await response.json();
242} catch (jsonError) {
243throw new Error(`Failed to parse GitHub API response: ${jsonError.message}`);
244}
245}
246247// Merge a PR via GitHub API
248async function mergePR(repo: string, prNumber: number) {
249const token = Deno.env.get("GITHUB_TOKEN");
282283// Proceed with merge
284const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}/merge`;
285286const response = await fetch(url, {
137138try {
139const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`;
140141const response = await fetch(url, {
166}
167} catch (error) {
168console.error("Exception during API call:", error);
169return { success: false, message: error.message };
170}
162}
163164const url = `https://api.github.com/repos/${repo}/issues/${issueNumber}`;
165166const response = await fetch(url, {
195196try {
197const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/labels`;
198199const response = await fetch(url, {