1import { createFetch } from "https://esm.sh/@better-fetch/fetch";
2
3export const $api = createFetch({
4 baseURL: "/api",
5});
1import { HTTPException } from "https://esm.sh/hono/http-exception";
2import * as db from "https://esm.town/v/nbbaier/hn_notifier/backend/database/queries.ts";
3import { DBItem, HNAPIResponse } from "https://esm.town/v/nbbaier/hn_notifier/shared/types.ts";
4import {
5 createDBItem,
19});
20
21const api = new Hono();
22
23api.get("/follow/:id", zValidator("param", idSchema), async c => {
24 const { id } = c.req.valid("param");
25 return c.text(`GET /follow/${id}`);
26});
27
28api.post("/follow", zValidator("json", z.object({ id: z.number() })), async (c) => {
29 const { id } = c.req.valid("json");
30 const { data, error } = await getHNItem(id);
48});
49
50api.get("/unfollow/:id", zValidator("param", idSchema), async c => {
51 const { id } = c.req.valid("param");
52 await db.unfollow(id);
54});
55
56api.get("/get/:id", zValidator("param", idSchema), async c => {
57 const { id } = c.req.valid("param");
58 const data = await db.getItem(id);
60});
61
62api.get("/list", async c => {
63 const urls = await db.getAllItems();
64 return c.json(urls);
65});
66
67api.get("/check", async c => {
68 return c.text("GET /check");
69});
70
71export default api;
57 name: f.title,
58 product: p.title,
59 json: `/api/${kp}.${kf}.json`,
60 atom: `/api/${kp}.${kf}.atom`,
61 rss: `/api/${kp}.${kf}.rss`,
62 }));
63
136 Object.entries(product.feeds).map(([feedKey, feed]) => `
137 <div>
138 <a href="/api/${productKey}.${feedKey}.rss" class="feed-link">
139 ${feed.title}
140 <span class="feed-type">RSS</span>
141 </a>
142 <a href="/api/${productKey}.${feedKey}.atom" class="feed-link">
143 ${feed.title}
144 <span class="feed-type">Atom</span>
145 </a>
146 <a href="/api/${productKey}.${feedKey}.json" class="feed-link">
147 ${feed.title}
148 <span class="feed-type">JSON</span>
175
176 // Existing feed generation route remains unchanged
177 const [, apiPath] = pathParts;
178 const [product, feed, ext] = apiPath.split(".");
179
180 if (!(product in QUERIES)) {
359 <meta name="viewport" content="width=device-width, initial-scale=1.0">
360 <title>Wired Components Playground</title>
361 <link href="https://fonts.googleapis.com/css2?family=Architects+Daughter&display=swap" rel="stylesheet">
362 <style>${css}</style>
363 </head>
398 <meta name="viewport" content="width=device-width, initial-scale=1.0">
399 <title>Sketchy Text Generator</title>
400 <link href="https://fonts.googleapis.com/css2?family=Architects+Daughter&display=swap" rel="stylesheet">
401 <style>${css}</style>
402 </head>
15```
16
17If you want to use an [api token](https://www.val.town/settings/api) to authenticate:
18
19```ts
280 <meta name="viewport" content="width=device-width, initial-scale=1.0">
281 <title>Hand-Drawn UI Elements with Rough.js</title>
282 <link href="https://fonts.googleapis.com/css2?family=Nanum+Pen+Script&display=swap" rel="stylesheet">
283 <style>${css}</style>
284 </head>
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
13
14// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
16
17// Unwrap and rethrow Hono errors as the original error
1import { useState, useEffect } from "https://esm.sh/react@18.2.0?dev";
2import { fetchProjectFiles } from "../utils/api.ts";
3
4interface UseProjectFilesProps {
6 project: any;
7 branchId: string | undefined;
8 anthropicApiKey: string;
9 bearerToken: string;
10 selectedFiles: string[];
16 project,
17 branchId,
18 anthropicApiKey,
19 bearerToken,
20 selectedFiles,
35 status,
36 } = useChat({
37 api: "/api/send-message",
38 body: {
39 project,
40 branchId,
41 anthropicApiKey,
42 selectedFiles,
43 images: images