10const PRICE_MULTIPLIER = 1.5;
11
12// Eventually we'll have a user database,
13// but in the meantime, we can cache user info in memory
14const userIdCache: { [key: string]: any } = {};
1import { Hono } from "npm:hono";
2import Stripe from "npm:stripe";
3import { getUser } from "../database/queries.tsx";
4import { getEnvVarName } from "../../shared/is-prod-branch.ts";
5
9import favicon from "./frontend/favicon.http.tsx";
10import loginRoute from "./frontend/routes/login.tsx";
11import adminDashboard from "./backend/database/usage-dashboard/index.ts";
12
13const SCOPE =
198```
199โโโ backend/
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
257 ```
258
259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
1import { Hono } from "npm:hono";
2import { getCreditBalance, getUser } from "../database/queries.tsx";
3
4const app = new Hono();
29
30- [React Hono Example](https://www.val.town/x/stevekrouse/reactHonoExample) is a
31 bigger example project, with a SQLite database table, queries, client-side
32 CSS, a favicon, and shared code that runs on both client and server.
29
30- [React Hono Example](https://www.val.town/x/stevekrouse/reactHonoExample) is a
31 bigger example project, with a SQLite database table, queries, client-side
32 CSS, a favicon, and shared code that runs on both client and server.
198```
199โโโ backend/
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
257 ```
258
259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
6 project, which is why it's in the folder above this one, even though it's
7 technically part of the backend
8- `database/` - this contains the code for interfacing with the app's SQLite
9 database table
10
11## Hono
41This app has two CRUD API routes: for reading and inserting into the messages
42table. They both speak JSON, which is standard. They import their functions from
43`/backend/database/queries.ts`. These routes are called from the React app to
44refresh and update data.
45
5} from "https://esm.town/v/std/utils/index.ts";
6import { Hono } from "npm:hono";
7import { getMessages, insertMessage } from "./backend/database/queries.ts";
8
9const app = new Hono();