- restructure from src/ + server/ to src/client/ + src/server/ + src/shared/ - switch backend runtime from Node (tsx) to Bun - merge server/package.json into root, remove @hono/node-server + tsx - convert server @/ imports to relative paths - standardize biome config (lineWidth 80, quoteStyle double) - add CLAUDE.md, .env.example at root - update vite.config, tsconfig, deploy.sh for new structure Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import type { PGlite } from "@electric-sql/pglite"
|
|
|
|
export interface Follow {
|
|
type: "topic" | "politician"
|
|
entity_id: number
|
|
label: string
|
|
}
|
|
|
|
export async function getFollows(db: PGlite): Promise<Follow[]> {
|
|
const res = await db.query<Follow>(
|
|
"SELECT type, entity_id, label FROM follows ORDER BY created_at",
|
|
)
|
|
return res.rows
|
|
}
|
|
|
|
export async function addFollow(
|
|
db: PGlite,
|
|
type: "topic" | "politician",
|
|
entityId: number,
|
|
label: string,
|
|
): Promise<void> {
|
|
await db.query(
|
|
"INSERT INTO follows (type, entity_id, label) VALUES ($1, $2, $3) ON CONFLICT DO NOTHING",
|
|
[type, entityId, label],
|
|
)
|
|
}
|
|
|
|
export async function removeFollow(
|
|
db: PGlite,
|
|
type: "topic" | "politician",
|
|
entityId: number,
|
|
): Promise<void> {
|
|
await db.query("DELETE FROM follows WHERE type = $1 AND entity_id = $2", [
|
|
type,
|
|
entityId,
|
|
])
|
|
}
|
|
|
|
export async function removeAllFollows(db: PGlite): Promise<void> {
|
|
await db.query("DELETE FROM follows")
|
|
}
|
|
|
|
export async function removeFollowsByType(
|
|
db: PGlite,
|
|
type: "topic" | "politician",
|
|
): Promise<void> {
|
|
await db.query("DELETE FROM follows WHERE type = $1", [type])
|
|
}
|