21 }));
22
23app.get("/api/counter/get", async c => c.json(await db.get("counter")));
24app.get("/api/counter/increment", async c => c.json(await db.set("counter", (await db.get("counter") || 0) + 1)));
25
26app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
58 <div className="">✷ Farcaster mini app manifest + webhook + embed metadata</div>
59 <div className="">✷ Farcaster notifications (storing tokens, sending recurring notifications, ...)</div>
60 <div className="">✷ Neynar API integration for Farcaster data</div>
61 <div className="">✷ Hosted on Val Town (instant deployments on save)</div>
62 <div className="">
72
73function Database() {
74 const queryFn = () => fetch("/api/counter/get").then((r) => r.json());
75 const { data, refetch } = useQuery({ queryKey: ["counter"], queryFn });
76 return (
78 {/* <h2 className="font-semibold">Database Example</h2> */}
79 <div className="">Counter value: {data}</div>
80 <Button variant="outline" onClick={() => fetch("/api/counter/increment").then(refetch)}>
81 Increment
82 </Button>
4 const TEXT = " Встерча и Работа ";
5
6 const url = `https://api.telegram.org/bot${TOKEN}/sendMessage`;
7
8 fetch(url, {
4 const TEXT = "🎨 Отдых";
5
6 const url = `https://api.telegram.org/bot${TOKEN}/sendMessage`;
7
8 fetch(url, {
4 const TEXT = "🤩 Служение и Семейное! ";
5
6 const url = `https://api.telegram.org/bot${TOKEN}/sendMessage`;
7
8 fetch(url, {
4 const TEXT = "👷♂️ Филиал ";
5
6 const url = `https://api.telegram.org/bot${TOKEN}/sendMessage`;
7
8 fetch(url, {
4 const TEXT = "🏢🚨 Lunes Monday Филиал ";
5
6 const url = `https://api.telegram.org/bot${TOKEN}/sendMessage`;
7
8 fetch(url, {
4 const TEXT = "🦺 Ezeiza";
5
6 const url = `https://api.telegram.org/bot${TOKEN}/sendMessage`;
7
8 fetch(url, {
4 const TEXT = "⏰ 8 часов работать";
5
6 const url = `https://api.telegram.org/bot${TOKEN}/sendMessage`;
7
8 fetch(url, {
8## Hono
9
10This app uses [Hono](https://hono.dev/) as the API framework. You can think of Hono as a replacement for [ExpressJS](https://expressjs.com/) that works in serverless environments like Val Town or Cloudflare Workers. If you come from Python or Ruby, Hono is also a lot like [Flask](https://github.com/pallets/flask) or [Sinatra](https://github.com/sinatra/sinatra), respectively.
11
12## Serving assets to the frontend
20### `index.html`
21
22The most complicated part of this backend API is serving index.html. In this app (like most apps) we serve it at the root, ie `GET /`.
23
24We *bootstrap* `index.html` with some initial data from the server, so that it gets dynamically injected JSON data without having to make another round-trip request to the server to get that data on the frontend. This is a common pattern for client-side rendered apps.
25
26## CRUD API Routes
27
28This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
29
30## Errors
31
32Hono and other API frameworks have a habit of swallowing up Errors. We turn off this default behavior by re-throwing errors, because we think most of the time you'll want to see the full stack trace instead of merely "Internal Server Error". You can customize how you want errors to appear.