Skip to content

[FEAT]: Implement System Logs Routes #116

@coxmars

Description

@coxmars

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.tsPOST 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.ts
  • src/components/modules/logs/schema/system-log.schema.ts

Validations

  • Log created with POST
  • Required + optional fields validated
  • metadata accepts JSON
  • created_at set automatically
  • Indexes used for performance
  • Response matches project standards

Tests

  • Creation → valid payload creates SystemLog
  • Validation → invalid returns 400
  • User referenceuser_id links correctly
  • Metadata → stored/retrieved as JSON
  • Error handling → consistent with other APIs
  • Index performance → queries use indexes
  • Response format → correct structure

⚠️ Please follow the guidelines for requesting an issue, launching commits, and describing PRs. Otherwise, they will be ignored. ⚠️

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions