Enhance ComboHandler and orchestrator functionality with access control and error handling improvements

- Added AccessControl to ComboHandler for role-based access management.
- Implemented gas estimation for plan execution and improved gas limit checks.
- Updated execution and preparation methods to enforce step count limits and role restrictions.
- Enhanced error handling in orchestrator API endpoints with AppError for better validation feedback.
- Integrated request timeout middleware for improved request management.
- Updated Swagger documentation to reflect new API structure and parameters.
This commit is contained in:
defiQUG
2025-11-05 17:55:48 -08:00
parent f600b7b15e
commit f52313e7c6
54 changed files with 3230 additions and 208 deletions

View File

@@ -0,0 +1,48 @@
import { cacheGet, cacheSet } from "./cache";
import { getPlanById } from "../db/plans";
/**
* Performance optimization utilities
*/
/**
* Get plan with caching
*/
export async function getPlanWithCache(planId: string) {
const cacheKey = `plan:${planId}`;
// Try cache first
const cached = await cacheGet(cacheKey);
if (cached) {
return cached;
}
// Get from database
const plan = await getPlanById(planId);
// Cache for 5 minutes
if (plan) {
await cacheSet(cacheKey, plan, 300);
}
return plan;
}
/**
* Batch API calls
*/
export async function batchApiCalls<T>(
calls: Array<() => Promise<T>>,
batchSize = 10
): Promise<T[]> {
const results: T[] = [];
for (let i = 0; i < calls.length; i += batchSize) {
const batch = calls.slice(i, i + batchSize);
const batchResults = await Promise.all(batch.map((call) => call()));
results.push(...batchResults);
}
return results;
}