Conversation
… logs Replace all console.* calls with pino structured logger. Add request ID middleware for tracing, pino-http for HTTP logging, per-request metrics collection to DB, and a fire-and-forget audit log system for admin actions. - Add pino/pino-http, remove morgan - Add ApiMetric and AuditLog Prisma models with migration - Add requestId, httpLogger, metricsCollector middleware - Add auditLog() helper used across 8 controllers - Add /api/developer endpoints (metrics + audit logs) - Add Developer section in admin with API Metrics and Audit Log pages - Metrics visible to MANAGER+, audit log restricted to SUPER_ADMIN Closes #14 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1cbaf65 to
f38de6c
Compare
Wrap the fire-and-forget audit log write in try-catch so that when prisma.auditLog is undefined (e.g. in mocked test environments), the synchronous TypeError is caught instead of bubbling up and preventing the controller from sending a response. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
console.*calls with pino structured logger (JSON in prod, pretty in dev, silent in test)x-request-idheader) for end-to-end tracingApiMetrictableauditLog()helper used across 8 controllers (staff, menu-item, category, order, coupon, settings, location, automation)GET /api/developer/metrics,GET /api/developer/metrics/endpoints,GET /api/developer/audit-logsCloses #14
Test plan
npx prisma migrate dev— migration createsapi_metricsandaudit_logstablesconsole.*outputx-request-idresponse header presentapi_metricstable has rows after requestsaudit_logstable has rows🤖 Generated with Claude Code