more lint fixes

This commit is contained in:
Boki 2025-06-20 08:54:56 -04:00
parent cc014de397
commit 3e545cdaa9
8 changed files with 29 additions and 38 deletions

View file

@ -68,7 +68,7 @@ export class RedisCache implements CacheProvider {
this.logger.info('Redis cache ready'); this.logger.info('Redis cache ready');
}); });
this.redis.on('error', (error: any) => { this.redis.on('error', (error: Error) => {
this.isConnected = false; this.isConnected = false;
this.logger.error('Redis cache connection error', { error: error.message }); this.logger.error('Redis cache connection error', { error: error.message });
}); });

View file

@ -12,6 +12,7 @@ import {
validateCompleteness validateCompleteness
} from './utils/validation'; } from './utils/validation';
import { redactSecrets } from './utils/secrets'; import { redactSecrets } from './utils/secrets';
import type { Environment } from './types';
interface CliOptions { interface CliOptions {
config?: string; config?: string;
@ -96,7 +97,7 @@ async function main() {
} }
const configPath = values.config || join(process.cwd(), 'config'); const configPath = values.config || join(process.cwd(), 'config');
const environment = values.env as any; const environment = values.env as Environment;
try { try {
const manager = new ConfigManager({ const manager = new ConfigManager({

View file

@ -59,7 +59,7 @@ export class ConfigManager<T = Record<string, unknown>> {
// Add environment if not present // Add environment if not present
if (typeof mergedConfig === 'object' && mergedConfig !== null && !('environment' in mergedConfig)) { if (typeof mergedConfig === 'object' && mergedConfig !== null && !('environment' in mergedConfig)) {
(mergedConfig as any).environment = this.environment; (mergedConfig as Record<string, unknown>)['environment'] = this.environment;
} }
// Validate if schema provided // Validate if schema provided

View file

@ -44,25 +44,28 @@ export function validateConfig<T>(
* Check for deprecated configuration options * Check for deprecated configuration options
*/ */
export function checkDeprecations( export function checkDeprecations(
config: Record<string, any>, config: Record<string, unknown>,
deprecations: Record<string, string> deprecations: Record<string, string>
): ValidationResult['warnings'] { ): ValidationResult['warnings'] {
const warnings: ValidationResult['warnings'] = []; const warnings: ValidationResult['warnings'] = [];
function checkObject(obj: any, path: string[] = []): void { function checkObject(obj: Record<string, unknown>, path: string[] = []): void {
for (const [key, value] of Object.entries(obj)) { for (const [key, value] of Object.entries(obj)) {
const currentPath = [...path, key]; const currentPath = [...path, key];
const pathStr = currentPath.join('.'); const pathStr = currentPath.join('.');
if (pathStr in deprecations) { if (pathStr in deprecations) {
warnings?.push({ const deprecationMessage = deprecations[pathStr];
path: pathStr, if (deprecationMessage) {
message: deprecations[pathStr]!, warnings?.push({
}); path: pathStr,
message: deprecationMessage,
});
}
} }
if (value && typeof value === 'object' && !Array.isArray(value)) { if (value && typeof value === 'object' && !Array.isArray(value)) {
checkObject(value, currentPath); checkObject(value as Record<string, unknown>, currentPath);
} }
} }
} }

View file

@ -23,7 +23,7 @@ export class HttpClient {
async post<T = any>( async post<T = any>(
url: string, url: string,
data?: any, data?: unknown,
config: Omit<RequestConfig, 'method' | 'url' | 'data'> = {} config: Omit<RequestConfig, 'method' | 'url' | 'data'> = {}
): Promise<HttpResponse<T>> { ): Promise<HttpResponse<T>> {
return this.request<T>({ ...config, method: 'POST', url, data }); return this.request<T>({ ...config, method: 'POST', url, data });
@ -31,7 +31,7 @@ export class HttpClient {
async put<T = any>( async put<T = any>(
url: string, url: string,
data?: any, data?: unknown,
config: Omit<RequestConfig, 'method' | 'url' | 'data'> = {} config: Omit<RequestConfig, 'method' | 'url' | 'data'> = {}
): Promise<HttpResponse<T>> { ): Promise<HttpResponse<T>> {
return this.request<T>({ ...config, method: 'PUT', url, data }); return this.request<T>({ ...config, method: 'PUT', url, data });
@ -46,7 +46,7 @@ export class HttpClient {
async patch<T = any>( async patch<T = any>(
url: string, url: string,
data?: any, data?: unknown,
config: Omit<RequestConfig, 'method' | 'url' | 'data'> = {} config: Omit<RequestConfig, 'method' | 'url' | 'data'> = {}
): Promise<HttpResponse<T>> { ): Promise<HttpResponse<T>> {
return this.request<T>({ ...config, method: 'PATCH', url, data }); return this.request<T>({ ...config, method: 'PATCH', url, data });

View file

@ -224,8 +224,8 @@ export class DeadLetterQueueHandler {
async inspectFailedJobs(limit = 10): Promise<Array<{ async inspectFailedJobs(limit = 10): Promise<Array<{
id: string; id: string;
name: string; name: string;
data: any; data: unknown;
error: any; error: unknown;
failedAt: string; failedAt: string;
attempts: number; attempts: number;
}>> { }>> {

View file

@ -1,6 +1,5 @@
import { Queue, QueueEvents } from 'bullmq'; import { Queue, QueueEvents } from 'bullmq';
// import { getLogger } from '@stock-bot/logger'; // import { getLogger } from '@stock-bot/logger';
import type { Job } from 'bullmq';
// const logger = getLogger('queue-metrics'); // const logger = getLogger('queue-metrics');
@ -41,6 +40,7 @@ export class QueueMetricsCollector {
private processingTimes: number[] = []; private processingTimes: number[] = [];
private completedTimestamps: number[] = []; private completedTimestamps: number[] = [];
private failedTimestamps: number[] = []; private failedTimestamps: number[] = [];
private jobStartTimes = new Map<string, number>();
private readonly maxSamples = 1000; private readonly maxSamples = 1000;
private readonly metricsInterval = 60000; // 1 minute private readonly metricsInterval = 60000; // 1 minute
@ -68,33 +68,20 @@ export class QueueMetricsCollector {
}); });
// Track processing times // Track processing times
this.queueEvents.on('active', async ({ jobId }) => { this.queueEvents.on('active', ({ jobId }) => {
const job = await this.getJob(jobId); this.jobStartTimes.set(jobId, Date.now());
if (job) {
(job as any)._startTime = Date.now();
}
}); });
this.queueEvents.on('completed', async ({ jobId }) => { this.queueEvents.on('completed', ({ jobId }) => {
const job = await this.getJob(jobId); const startTime = this.jobStartTimes.get(jobId);
if (job && (job as any)._startTime) { if (startTime) {
const processingTime = Date.now() - (job as any)._startTime; const processingTime = Date.now() - startTime;
this.recordProcessingTime(processingTime); this.recordProcessingTime(processingTime);
this.jobStartTimes.delete(jobId);
} }
}); });
} }
/**
* Get job by ID
*/
private async getJob(jobId: string): Promise<Job | undefined> {
try {
return await this.queue.getJob(jobId) || undefined;
} catch {
return undefined;
}
}
/** /**
* Record processing time * Record processing time
*/ */

View file

@ -169,12 +169,12 @@ export interface DLQJobInfo {
failedReason: string; failedReason: string;
attemptsMade: number; attemptsMade: number;
timestamp: number; timestamp: number;
data: any; data: unknown;
} }
export interface ScheduleConfig { export interface ScheduleConfig {
pattern: string; pattern: string;
jobName: string; jobName: string;
data?: any; data?: unknown;
options?: JobOptions; options?: JobOptions;
} }