- apps/web: Vite + React 19 + TanStack Router/Query + shadcn/ui - apps/api: Hono + Bun on :3001 with /api/health, /api/auth/*, /mcp stubs - apps/worker: Bun worker stub, DB connection, graceful SIGTERM - apps/web-legacy/: old Next.js code moved aside (preserved for T2-T8 reference) - Dockerfiles: api (Bun), worker (Bun), spa (multi-stage Caddy) - Caddyfile: serves dist + reverse-proxies /api/* + /mcp to api - docker-compose.yml: 4-service target (api, spa, db, worker) - packages/db/src/client.ts: shared Drizzle client for api + worker - db/client.ts: root-level alias for convenience Parent: t_e1cbd87d -> t_24c9c3fd (T0)
32 lines
896 B
TypeScript
32 lines
896 B
TypeScript
import { db, sql, activityFeed } from '@project-e/db';
|
|
|
|
export interface RecordActivityParams {
|
|
actor: string;
|
|
action: string;
|
|
entityType: string;
|
|
entityId: string;
|
|
changes?: Record<string, unknown>;
|
|
workspaceId: string;
|
|
}
|
|
|
|
/**
|
|
* Record an activity feed entry and fire a pg_notify event.
|
|
* Every write API route MUST call this after every INSERT/UPDATE/DELETE.
|
|
*/
|
|
export async function recordActivity(params: RecordActivityParams): Promise<void> {
|
|
const { actor, action, entityType, entityId, changes, workspaceId } = params;
|
|
|
|
await db.insert(activityFeed).values({
|
|
actor,
|
|
action,
|
|
entityType,
|
|
entityId,
|
|
changes: changes ?? null,
|
|
workspaceId,
|
|
});
|
|
|
|
// Notify SSE subscribers
|
|
const payload = JSON.stringify({ type: entityType, action, id: entityId, workspace_id: workspaceId });
|
|
await sql`SELECT pg_notify('project_e_events', ${payload}::text)`;
|
|
}
|