-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Labels
Description
Implement System Logs API Route
Description
Create API routes for system log operations with Prisma + Zod validation. Follow existing patterns for routes, error handling, and database optimization.
Requirements
API Route
- Create
src/app/api/(logs)/logs/create/route.ts→ POST endpoint - Follow existing grouped route structure
(logs) - Use consistent imports & method handling
Validation
- Add Zod schema →
src/components/modules/logs/schema/system-log.schema.ts - Required:
action,description - Optional:
user_id,entity_type,metadata (JSON) - Follow
auth/schema/style
Database
- Use
@/lib/prisma+handleDatabaseError - Implement SystemLog with Prisma ORM
- Use indexes:
user_id,entity_type,created_at
Components
src/app/api/(logs)/logs/create/route.tssrc/components/modules/logs/schema/system-log.schema.ts
Validations
- Log created with
POST - Required + optional fields validated
-
metadataaccepts JSON -
created_atset automatically - Indexes used for performance
- Response matches project standards
Tests
- Creation → valid payload creates
SystemLog - Validation → invalid returns 400
- User reference →
user_idlinks correctly - Metadata → stored/retrieved as JSON
- Error handling → consistent with other APIs
- Index performance → queries use indexes
- Response format → correct structure