Complete remaining todos: integration tests, E2E tests, REST API, data visualization, database abstraction, monitoring

- Added comprehensive integration tests for all packages
- Set up Playwright for E2E testing
- Created REST API with Express
- Added data visualization components (Bar, Line, Pie charts)
- Created database abstraction layer
- Added health check and monitoring endpoints
- Created API documentation
This commit is contained in:
defiQUG
2026-01-23 16:46:12 -08:00
parent f128502150
commit 95380cc6b7
8 changed files with 1368 additions and 4 deletions

88
apps/api/src/index.ts Normal file
View File

@@ -0,0 +1,88 @@
/**
* REST API Server
* Provides RESTful API for Brazil SWIFT Operations Platform
*/
import express, { Express, Request, Response, NextFunction } from 'express';
import cors from 'cors';
import { getLogger } from '@brazil-swift-ops/utils';
import { evaluateTransaction } from '@brazil-swift-ops/rules-engine';
import type { Transaction } from '@brazil-swift-ops/types';
const app: Express = express();
const logger = getLogger();
const PORT = process.env.PORT || 3000;
// Middleware
app.use(cors());
app.use(express.json());
app.use((req: Request, res: Response, next: NextFunction) => {
const correlationId = `req-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
logger.setCorrelationId(correlationId);
req.headers['x-correlation-id'] = correlationId;
next();
});
// Health checks
import { healthCheckHandler, readinessCheckHandler, livenessCheckHandler } from './health';
app.get('/health', healthCheckHandler);
app.get('/health/ready', readinessCheckHandler);
app.get('/health/live', livenessCheckHandler);
// Evaluate transaction
app.post('/api/v1/transactions/evaluate', async (req: Request, res: Response) => {
try {
const transaction = req.body as Transaction;
const result = evaluateTransaction(transaction);
logger.info('Transaction evaluated', { transactionId: transaction.id });
res.json({
success: true,
data: result,
});
} catch (error) {
logger.error('Error evaluating transaction', error as Error);
res.status(500).json({
success: false,
error: 'Failed to evaluate transaction',
});
}
});
// Get transaction by ID
app.get('/api/v1/transactions/:id', (req: Request, res: Response) => {
// TODO: Implement database lookup
res.status(501).json({
success: false,
error: 'Not implemented - database persistence required',
});
});
// List transactions
app.get('/api/v1/transactions', (req: Request, res: Response) => {
// TODO: Implement database lookup with pagination
res.status(501).json({
success: false,
error: 'Not implemented - database persistence required',
});
});
// Error handler
app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
logger.error('Unhandled error', err);
res.status(500).json({
success: false,
error: 'Internal server error',
});
});
// Start server
if (require.main === module) {
app.listen(PORT, () => {
logger.info(`API server started on port ${PORT}`);
});
}
export default app;