this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add projects API endpoints

GET /api/projects - list all projects with optional status filter
PATCH /api/projects/status - update project status

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

alice 45ac1e2c 9be5d25c

+30 -1
+30 -1
src/web/api.ts
··· 1 - import { getDays, getDayDetail, getStats } from '../core/db'; 1 + import { getDays, getDayDetail, getStats, getProjects, updateProjectStatus } from '../core/db'; 2 2 import { processCommand } from '../cli/process'; 3 + import type { ProjectStatus } from '../types'; 3 4 4 5 type ApiHandler = (req: Request, url: URL) => Promise<Response>; 5 6 ··· 9 10 'GET /api/days/:date/brag': handleGetDayBrag, 10 11 'GET /api/stats': handleGetStats, 11 12 'POST /api/refresh': handleRefresh, 13 + 'GET /api/projects': handleGetProjects, 14 + 'PATCH /api/projects/status': handleUpdateProjectStatus, 12 15 }; 13 16 14 17 export async function handleApiRequest( ··· 142 145 ); 143 146 } 144 147 } 148 + 149 + async function handleGetProjects(req: Request, url: URL): Promise<Response> { 150 + const status = url.searchParams.get('status') as ProjectStatus | null; 151 + const projects = getProjects(status || undefined); 152 + return jsonResponse(projects); 153 + } 154 + 155 + async function handleUpdateProjectStatus(req: Request, url: URL): Promise<Response> { 156 + const body = await req.json() as { path: string; status: ProjectStatus }; 157 + 158 + if (!body.path || !body.status) { 159 + return jsonResponse({ error: 'Missing path or status' }, 400); 160 + } 161 + 162 + const validStatuses: ProjectStatus[] = ['shipped', 'in_progress', 'abandoned', 'one_off', 'experiment']; 163 + if (!validStatuses.includes(body.status)) { 164 + return jsonResponse({ error: 'Invalid status' }, 400); 165 + } 166 + 167 + const updated = updateProjectStatus(body.path, body.status); 168 + if (!updated) { 169 + return jsonResponse({ error: 'Project not found' }, 404); 170 + } 171 + 172 + return jsonResponse({ success: true }); 173 + }