diff --git a/libs/cache/src/redis-cache.ts b/libs/cache/src/redis-cache.ts index 215d49d..7fcab9e 100644 --- a/libs/cache/src/redis-cache.ts +++ b/libs/cache/src/redis-cache.ts @@ -68,7 +68,7 @@ export class RedisCache implements CacheProvider { this.logger.info('Redis cache ready'); }); - this.redis.on('error', (error: any) => { + this.redis.on('error', (error: Error) => { this.isConnected = false; this.logger.error('Redis cache connection error', { error: error.message }); }); diff --git a/libs/config/src/cli.ts b/libs/config/src/cli.ts index b0fe42b..d3cfced 100644 --- a/libs/config/src/cli.ts +++ b/libs/config/src/cli.ts @@ -12,6 +12,7 @@ import { validateCompleteness } from './utils/validation'; import { redactSecrets } from './utils/secrets'; +import type { Environment } from './types'; interface CliOptions { config?: string; @@ -96,7 +97,7 @@ async function main() { } const configPath = values.config || join(process.cwd(), 'config'); - const environment = values.env as any; + const environment = values.env as Environment; try { const manager = new ConfigManager({ diff --git a/libs/config/src/config-manager.ts b/libs/config/src/config-manager.ts index 246340d..0bfa701 100644 --- a/libs/config/src/config-manager.ts +++ b/libs/config/src/config-manager.ts @@ -59,7 +59,7 @@ export class ConfigManager> { // Add environment if not present if (typeof mergedConfig === 'object' && mergedConfig !== null && !('environment' in mergedConfig)) { - (mergedConfig as any).environment = this.environment; + (mergedConfig as Record)['environment'] = this.environment; } // Validate if schema provided diff --git a/libs/config/src/utils/validation.ts b/libs/config/src/utils/validation.ts index 7eb54ed..5b61b82 100644 --- a/libs/config/src/utils/validation.ts +++ b/libs/config/src/utils/validation.ts @@ -44,25 +44,28 @@ export function validateConfig( * Check for deprecated configuration options */ export function checkDeprecations( - config: Record, + config: Record, deprecations: Record ): ValidationResult['warnings'] { const warnings: ValidationResult['warnings'] = []; - function checkObject(obj: any, path: string[] = []): void { + function checkObject(obj: Record, path: string[] = []): void { for (const [key, value] of Object.entries(obj)) { const currentPath = [...path, key]; const pathStr = currentPath.join('.'); if (pathStr in deprecations) { - warnings?.push({ - path: pathStr, - message: deprecations[pathStr]!, - }); + const deprecationMessage = deprecations[pathStr]; + if (deprecationMessage) { + warnings?.push({ + path: pathStr, + message: deprecationMessage, + }); + } } if (value && typeof value === 'object' && !Array.isArray(value)) { - checkObject(value, currentPath); + checkObject(value as Record, currentPath); } } } diff --git a/libs/http/src/client.ts b/libs/http/src/client.ts index 07609ae..c02382a 100644 --- a/libs/http/src/client.ts +++ b/libs/http/src/client.ts @@ -23,7 +23,7 @@ export class HttpClient { async post( url: string, - data?: any, + data?: unknown, config: Omit = {} ): Promise> { return this.request({ ...config, method: 'POST', url, data }); @@ -31,7 +31,7 @@ export class HttpClient { async put( url: string, - data?: any, + data?: unknown, config: Omit = {} ): Promise> { return this.request({ ...config, method: 'PUT', url, data }); @@ -46,7 +46,7 @@ export class HttpClient { async patch( url: string, - data?: any, + data?: unknown, config: Omit = {} ): Promise> { return this.request({ ...config, method: 'PATCH', url, data }); diff --git a/libs/queue/src/dlq-handler.ts b/libs/queue/src/dlq-handler.ts index 9b643af..76b2a2d 100644 --- a/libs/queue/src/dlq-handler.ts +++ b/libs/queue/src/dlq-handler.ts @@ -224,8 +224,8 @@ export class DeadLetterQueueHandler { async inspectFailedJobs(limit = 10): Promise> { diff --git a/libs/queue/src/queue-metrics.ts b/libs/queue/src/queue-metrics.ts index 8fa66b9..c74ada5 100644 --- a/libs/queue/src/queue-metrics.ts +++ b/libs/queue/src/queue-metrics.ts @@ -1,6 +1,5 @@ import { Queue, QueueEvents } from 'bullmq'; // import { getLogger } from '@stock-bot/logger'; -import type { Job } from 'bullmq'; // const logger = getLogger('queue-metrics'); @@ -41,6 +40,7 @@ export class QueueMetricsCollector { private processingTimes: number[] = []; private completedTimestamps: number[] = []; private failedTimestamps: number[] = []; + private jobStartTimes = new Map(); private readonly maxSamples = 1000; private readonly metricsInterval = 60000; // 1 minute @@ -68,33 +68,20 @@ export class QueueMetricsCollector { }); // Track processing times - this.queueEvents.on('active', async ({ jobId }) => { - const job = await this.getJob(jobId); - if (job) { - (job as any)._startTime = Date.now(); - } + this.queueEvents.on('active', ({ jobId }) => { + this.jobStartTimes.set(jobId, Date.now()); }); - this.queueEvents.on('completed', async ({ jobId }) => { - const job = await this.getJob(jobId); - if (job && (job as any)._startTime) { - const processingTime = Date.now() - (job as any)._startTime; + this.queueEvents.on('completed', ({ jobId }) => { + const startTime = this.jobStartTimes.get(jobId); + if (startTime) { + const processingTime = Date.now() - startTime; this.recordProcessingTime(processingTime); + this.jobStartTimes.delete(jobId); } }); } - /** - * Get job by ID - */ - private async getJob(jobId: string): Promise { - try { - return await this.queue.getJob(jobId) || undefined; - } catch { - return undefined; - } - } - /** * Record processing time */ diff --git a/libs/queue/src/types.ts b/libs/queue/src/types.ts index 1c21286..82104c8 100644 --- a/libs/queue/src/types.ts +++ b/libs/queue/src/types.ts @@ -169,12 +169,12 @@ export interface DLQJobInfo { failedReason: string; attemptsMade: number; timestamp: number; - data: any; + data: unknown; } export interface ScheduleConfig { pattern: string; jobName: string; - data?: any; + data?: unknown; options?: JobOptions; }