Hono-based API server that provides authentication and CRUD operations for notes and receipts using PocketBase.
The backend uses a generic CRUD factory pattern to eliminate code duplication between similar resources:
crud-factory.ts - Generic CRUD route factoryresource-configs.ts - Resource-specific configurations for notes and receiptsindex.ts - Main application setup and auth routesPOCKETBASE_URL - Your PocketBase instance URLPOST /api/auth/login - Login with email/passwordPOST /api/auth/logout - Logout (requires auth)GET /api/auth/me - Get current user info (requires auth)GET /api/notes - Get all notes for authenticated userPOST /api/notes - Create a new notePUT /api/notes/:id - Update a noteDELETE /api/notes/:id - Delete a note (hard delete)GET /api/receipts - Get all non-trashed receipts for authenticated userPOST /api/receipts - Create a new receiptPUT /api/receipts/:id - Update a receiptDELETE /api/receipts/:id - Delete a receipt (soft delete - sets trashed=true)All resource endpoints require authentication via Bearer token in Authorization header.
To add a new resource type (e.g., tasks, bookmarks):
shared/types.tsresource-configs.tsindex.ts using createCrudRoutes()Example:
// In resource-configs.ts
export const tasksConfig: ResourceConfig<Task, CreateTaskRequest, UpdateTaskRequest> = {
collectionName: "tasks",
mapRecord: (record: any): Task => ({ /* mapping logic */ }),
createData: (req: CreateTaskRequest) => ({ /* create data */ }),
updateData: (req: UpdateTaskRequest) => ({ /* update data */ }),
};
// In index.ts
createCrudRoutes(app, "/tasks", tasksConfig, pb, requireAuth);
/ - Serves the main HTML page/notes - Serves the notes page/receipts - Serves the receipts page/frontend/* - Serves frontend React components/shared/* - Serves shared TypeScript types