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
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
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
146```
147โโโ backend/
148โ โโโ database.ts # SQLite database setup and queries
149โ โโโ README.md # Backend documentation
150โ โโโ routes/
1import { recordPurchase } from "../database.ts";
2import type {
3 ThriveCartWebhookPayload,
5 getPurchaseCount,
6 getRecentPurchases,
7} from "../database.ts";
8
9const purchases = new Hono();
3import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
4import * as Sentry from "https://deno.land/x/sentry/index.mjs";
5import { initDatabase } from "./backend/database.ts";
6import { handlePurchaseWebhook } from "./backend/webhooks/purchase.ts";
7import { handleEventSignupWebhook } from "./backend/webhooks/events.ts";
37
38
39await initDatabase();
40
41// A 200 response from GET is required to save a webhook in Thrivecart
1import { recordEventSignup } from "../database.ts";
2
3export async function handleEventSignupWebhook(eventName: string) {
5 getAllSignups,
6 getEventSignupCountInPeriod,
7} from "../database.ts";
8
9const events = new Hono();
20}
21
22export async function initDatabase() {
23 await sqlite.execute(`
24 CREATE TABLE IF NOT EXISTS ${PURCHASES_TABLE} (