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.redis.on('error', (error: any) => {
this.redis.on('error', (error: Error) => {
this.isConnected = false;
this.logger.error('Redis cache connection error', { error: error.message });
});

View file

@ -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({

View file

@ -59,7 +59,7 @@ export class ConfigManager<T = Record<string, unknown>> {
// Add environment if not present
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

View file

@ -44,25 +44,28 @@ export function validateConfig<T>(
* Check for deprecated configuration options
*/
export function checkDeprecations(
config: Record<string, any>,
config: Record<string, unknown>,
deprecations: Record<string, string>
): 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)) {
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<string, unknown>, currentPath);
}
}
}

View file

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

View file

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

View file

@ -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<string, number>();
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<Job | undefined> {
try {
return await this.queue.getJob(jobId) || undefined;
} catch {
return undefined;
}
}
/**
* Record processing time
*/

View file

@ -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;
}