This commit introduces a complete transparency infrastructure including: Core Transparency Modules: - AuditLog: Immutable, cryptographically-linked audit trail for all actions - EventStream: Real-time SSE streaming and webhook support - TransparencyDashboard: Aggregated metrics and system health monitoring - DigitalSignatures: Cryptographic verification for handoffs and certificates API Endpoints: - /api/transparency/dashboard - Full platform metrics - /api/transparency/audit - Query and log audit entries - /api/transparency/events - SSE stream and event history - /api/transparency/webhooks - Webhook management - /api/transparency/signatures - Digital signature operations - /api/transparency/certificate/[plantId] - Plant authenticity certificates - /api/transparency/export - Multi-format data export - /api/transparency/report - Compliance reporting - /api/transparency/health - System health checks Features: - Immutable audit logging with chain integrity verification - Real-time event streaming via Server-Sent Events - Webhook support with HMAC signature verification - Digital signatures for transport handoffs and ownership transfers - Certificate of Authenticity generation for plants - Multi-format data export (JSON, CSV, summary) - Public transparency portal at /transparency - System health monitoring for all components Documentation: - Comprehensive TRANSPARENCY.md guide with API examples
37 lines
968 B
TypeScript
37 lines
968 B
TypeScript
/**
|
|
* Transparency Dashboard API
|
|
* GET /api/transparency/dashboard
|
|
*
|
|
* Returns comprehensive transparency metrics for the entire platform.
|
|
*/
|
|
|
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
import { getTransparencyDashboard } from '../../../lib/transparency';
|
|
|
|
export default async function handler(
|
|
req: NextApiRequest,
|
|
res: NextApiResponse
|
|
) {
|
|
if (req.method !== 'GET') {
|
|
return res.status(405).json({ error: 'Method not allowed' });
|
|
}
|
|
|
|
try {
|
|
const dashboard = getTransparencyDashboard();
|
|
const data = await dashboard.getDashboard();
|
|
|
|
// Add cache headers for performance
|
|
res.setHeader('Cache-Control', 'public, s-maxage=10, stale-while-revalidate=59');
|
|
|
|
return res.status(200).json({
|
|
success: true,
|
|
data
|
|
});
|
|
} catch (error) {
|
|
console.error('[API] Dashboard error:', error);
|
|
return res.status(500).json({
|
|
success: false,
|
|
error: 'Failed to fetch dashboard data'
|
|
});
|
|
}
|
|
}
|