fixed all lint errors
This commit is contained in:
parent
519d24722e
commit
26d9b9ab3f
23 changed files with 63 additions and 43 deletions
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import {
|
||||
BaseHandler,
|
||||
Disabled,
|
||||
Handler,
|
||||
Operation,
|
||||
ScheduledOperation,
|
||||
|
|
@ -13,6 +14,7 @@ import {
|
|||
} from '@stock-bot/handlers';
|
||||
|
||||
@Handler('example')
|
||||
@Disabled()
|
||||
export class ExampleHandler extends BaseHandler {
|
||||
constructor(services: IServiceContainer) {
|
||||
super(services);
|
||||
|
|
@ -86,7 +88,7 @@ export class ExampleHandler extends BaseHandler {
|
|||
* Complex operation that still uses action file
|
||||
*/
|
||||
@Operation('process-batch')
|
||||
async processBatch(input: any, context: ExecutionContext): Promise<unknown> {
|
||||
async processBatch(input: any, _context: ExecutionContext): Promise<unknown> {
|
||||
// For complex operations, still use action files
|
||||
const { processBatch } = await import('./actions/batch.action');
|
||||
return processBatch(this, input);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Proxy Check Operations - Checking proxy functionality
|
||||
*/
|
||||
import { OperationContext } from '@stock-bot/di';
|
||||
import type { OperationContext } from '@stock-bot/di';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { ProxyInfo } from '@stock-bot/proxy';
|
||||
import { fetch } from '@stock-bot/utils';
|
||||
|
|
@ -13,7 +13,7 @@ import { PROXY_CONFIG } from '../shared/config';
|
|||
export async function checkProxy(proxy: ProxyInfo): Promise<ProxyInfo> {
|
||||
const ctx = {
|
||||
logger: getLogger('proxy-check'),
|
||||
resolve: <T>(_name: string) => {
|
||||
resolve: (_name: string) => {
|
||||
throw new Error(`Service container not available for proxy operations`);
|
||||
},
|
||||
} as any;
|
||||
|
|
@ -99,7 +99,7 @@ async function updateProxyInCache(
|
|||
isWorking: boolean,
|
||||
ctx: OperationContext
|
||||
): Promise<void> {
|
||||
const _cacheKey = `${PROXY_CONFIG.CACHE_KEY}:${proxy.protocol}://${proxy.host}:${proxy.port}`;
|
||||
// const _cacheKey = `${PROXY_CONFIG.CACHE_KEY}:${proxy.protocol}://${proxy.host}:${proxy.port}`;
|
||||
|
||||
try {
|
||||
// For now, skip cache operations without service container
|
||||
|
|
@ -147,7 +147,7 @@ async function updateProxyInCache(
|
|||
updated.successRate = updated.total > 0 ? (updated.working / updated.total) * 100 : 0;
|
||||
|
||||
// Save to cache: reset TTL for working proxies, keep existing TTL for failed ones
|
||||
const _cacheOptions = isWorking ? { ttl: PROXY_CONFIG.CACHE_TTL } : undefined;
|
||||
// const _cacheOptions = isWorking ? { ttl: PROXY_CONFIG.CACHE_TTL } : undefined;
|
||||
// Skip cache operations without service container
|
||||
// TODO: Pass service container to operations
|
||||
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ export async function createSingleSession(
|
|||
handler: BaseHandler,
|
||||
input: any
|
||||
): Promise<{ sessionId: string; status: string; sessionType: string }> {
|
||||
const { sessionId, sessionType } = input || {};
|
||||
const sessionManager = QMSessionManager.getInstance();
|
||||
const { sessionId: _sessionId, sessionType } = input || {};
|
||||
const _sessionManager = QMSessionManager.getInstance();
|
||||
|
||||
// Get proxy from proxy service
|
||||
const proxyString = handler.proxy.getProxy();
|
||||
const _proxyString = handler.proxy.getProxy();
|
||||
|
||||
// const session = {
|
||||
// proxy: proxyString || 'http://proxy:8080',
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ const app = new ServiceApplication(
|
|||
},
|
||||
{
|
||||
// Lifecycle hooks if needed
|
||||
onStarted: (port) => {
|
||||
onStarted: (_port) => {
|
||||
const logger = getLogger('data-ingestion');
|
||||
logger.info('Data ingestion service startup initiated with ServiceApplication framework');
|
||||
},
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ const app = new ServiceApplication(
|
|||
const enhancedContainer = setupServiceContainer(config, container);
|
||||
return enhancedContainer;
|
||||
},
|
||||
onStarted: (port) => {
|
||||
onStarted: (_port) => {
|
||||
const logger = getLogger('data-pipeline');
|
||||
logger.info('Data pipeline service startup initiated with ServiceApplication framework');
|
||||
},
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ const app = new ServiceApplication(
|
|||
},
|
||||
{
|
||||
// Custom lifecycle hooks
|
||||
onStarted: (port) => {
|
||||
onStarted: (_port) => {
|
||||
const logger = getLogger('web-api');
|
||||
logger.info('Web API service startup initiated with ServiceApplication framework');
|
||||
},
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import type {
|
|||
DatabaseStats,
|
||||
SystemHealth,
|
||||
ServiceMetrics,
|
||||
MetricSnapshot,
|
||||
ServiceStatus,
|
||||
ProxyStats,
|
||||
SystemOverview
|
||||
|
|
@ -196,7 +195,7 @@ export class MonitoringService {
|
|||
/**
|
||||
* Get stats for a specific queue
|
||||
*/
|
||||
private async getQueueStatsForQueue(queue: any, queueName: string) {
|
||||
private async getQueueStatsForQueue(queue: any, _queueName: string) {
|
||||
// Check if it has the getStats method
|
||||
if (queue.getStats && typeof queue.getStats === 'function') {
|
||||
const stats = await queue.getStats();
|
||||
|
|
@ -240,7 +239,7 @@ export class MonitoringService {
|
|||
try {
|
||||
const result = await queue[methodName]();
|
||||
return Array.isArray(result) ? result.length : (result || 0);
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
// Continue to next method
|
||||
}
|
||||
}
|
||||
|
|
@ -260,7 +259,7 @@ export class MonitoringService {
|
|||
if (queue.getPausedCount && typeof queue.getPausedCount === 'function') {
|
||||
return await queue.getPausedCount();
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
// Ignore
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -269,7 +268,7 @@ export class MonitoringService {
|
|||
/**
|
||||
* Get worker info for a queue
|
||||
*/
|
||||
private getWorkerInfo(queue: any, queueManager: any, queueName: string) {
|
||||
private getWorkerInfo(queue: any, queueManager: any, _queueName: string) {
|
||||
try {
|
||||
// Check queue itself for worker info
|
||||
if (queue.workers && Array.isArray(queue.workers)) {
|
||||
|
|
@ -296,7 +295,7 @@ export class MonitoringService {
|
|||
concurrency: 1,
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
|
|
@ -313,7 +312,7 @@ export class MonitoringService {
|
|||
if (this.container.postgres) {
|
||||
try {
|
||||
const startTime = Date.now();
|
||||
const result = await this.container.postgres.query('SELECT 1');
|
||||
const _result = await this.container.postgres.query('SELECT 1');
|
||||
const latency = Date.now() - startTime;
|
||||
|
||||
// Get pool stats
|
||||
|
|
@ -540,7 +539,7 @@ export class MonitoringService {
|
|||
const response = await fetch(`http://localhost:${service.port}${service.path}`, {
|
||||
signal: AbortSignal.timeout(5000), // 5 second timeout
|
||||
});
|
||||
const latency = Date.now() - startTime;
|
||||
const _latency = Date.now() - startTime;
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
|
|
@ -704,13 +703,13 @@ export class MonitoringService {
|
|||
const lines = meminfo.split('\n');
|
||||
|
||||
let memAvailable = 0;
|
||||
let memTotal = 0;
|
||||
let _memTotal = 0;
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.startsWith('MemAvailable:')) {
|
||||
memAvailable = parseInt(line.split(/\s+/)[1], 10) * 1024; // Convert from KB to bytes
|
||||
} else if (line.startsWith('MemTotal:')) {
|
||||
memTotal = parseInt(line.split(/\s+/)[1], 10) * 1024;
|
||||
_memTotal = parseInt(line.split(/\s+/)[1], 10) * 1024;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
3
bun.lock
3
bun.lock
|
|
@ -36,6 +36,7 @@
|
|||
"pg-mem": "^2.8.1",
|
||||
"prettier": "^3.5.3",
|
||||
"supertest": "^6.3.4",
|
||||
"ts-unused-exports": "^11.0.1",
|
||||
"turbo": "^2.5.4",
|
||||
"typescript": "^5.8.3",
|
||||
"yup": "^1.6.1",
|
||||
|
|
@ -2260,6 +2261,8 @@
|
|||
|
||||
"ts-interface-checker": ["ts-interface-checker@0.1.13", "", {}, "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA=="],
|
||||
|
||||
"ts-unused-exports": ["ts-unused-exports@11.0.1", "", { "dependencies": { "chalk": "^4.0.0", "tsconfig-paths": "^3.9.0" }, "peerDependencies": { "typescript": ">=3.8.3" }, "bin": { "ts-unused-exports": "bin/ts-unused-exports" } }, "sha512-b1uIe0B8YfNZjeb+bx62LrB6qaO4CHT8SqMVBkwbwLj7Nh0xQ4J8uV0dS9E6AABId0U4LQ+3yB/HXZBMslGn2A=="],
|
||||
|
||||
"tsconfig-paths": ["tsconfig-paths@3.15.0", "", { "dependencies": { "@types/json5": "^0.0.29", "json5": "^1.0.2", "minimist": "^1.2.6", "strip-bom": "^3.0.0" } }, "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg=="],
|
||||
|
||||
"tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ export default [
|
|||
argsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_',
|
||||
destructuredArrayIgnorePattern: '^_',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
},
|
||||
],
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
|
|
|
|||
|
|
@ -147,13 +147,13 @@ export function getLoggingConfig() {
|
|||
|
||||
// Deprecated - provider configs should be app-specific
|
||||
// @deprecated Move provider configs to your app-specific config
|
||||
export function getProviderConfig(provider: string) {
|
||||
export function getProviderConfig(_provider: string) {
|
||||
const config = getConfig() as any;
|
||||
const providers = config.providers;
|
||||
if (!providers || !(provider in providers)) {
|
||||
throw new Error(`Provider configuration not found: ${provider}`);
|
||||
if (!providers || !(_provider in providers)) {
|
||||
throw new Error(`Provider configuration not found: ${_provider}`);
|
||||
}
|
||||
return (providers as Record<string, unknown>)[provider];
|
||||
return (providers as Record<string, unknown>)[_provider];
|
||||
}
|
||||
|
||||
export function getQueueConfig() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { z } from 'zod';
|
||||
import { baseConfigSchema, environmentSchema } from './base.schema';
|
||||
import { environmentSchema } from './base.schema';
|
||||
import {
|
||||
postgresConfigSchema,
|
||||
mongodbConfigSchema,
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ import { join } from 'path';
|
|||
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
||||
import { ConfigManager } from '../src/config-manager';
|
||||
import { initializeConfig, initializeServiceConfig, resetConfig } from '../src/index';
|
||||
import { EnvLoader } from '../src/loaders/env.loader';
|
||||
import { FileLoader } from '../src/loaders/file.loader';
|
||||
import { appConfigSchema } from '../src/schemas';
|
||||
|
||||
// Test directories setup
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import { chmodSync, existsSync, mkdirSync, rmSync, writeFileSync } from 'fs';
|
|||
import { join } from 'path';
|
||||
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
||||
import { ConfigManager } from '../src/config-manager';
|
||||
import { ConfigError, ConfigValidationError } from '../src/errors';
|
||||
import { initializeConfig, initializeServiceConfig, resetConfig } from '../src/index';
|
||||
import { ConfigValidationError } from '../src/errors';
|
||||
import { initializeConfig, resetConfig } from '../src/index';
|
||||
import { EnvLoader } from '../src/loaders/env.loader';
|
||||
import { FileLoader } from '../src/loaders/file.loader';
|
||||
import { appConfigSchema } from '../src/schemas';
|
||||
|
|
@ -225,7 +225,7 @@ JSON_VALUE={"key": "value", "nested": {"array": [1, 2, 3]}}
|
|||
loaders: [new EnvLoader('')],
|
||||
});
|
||||
|
||||
const config = await manager.initialize();
|
||||
const _config = await manager.initialize();
|
||||
|
||||
// Should handle valid entries
|
||||
expect(process.env.VALID_KEY).toBe('valid_value');
|
||||
|
|
@ -276,7 +276,7 @@ JSON_VALUE={"key": "value", "nested": {"array": [1, 2, 3]}}
|
|||
loaders: [new EnvLoader('')],
|
||||
});
|
||||
|
||||
const config = await manager.initialize(appConfigSchema);
|
||||
const _config = await manager.initialize(appConfigSchema);
|
||||
|
||||
// Should throw for invalid paths
|
||||
expect(() => manager.getValue('nonexistent.path')).toThrow('Configuration key not found');
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ describe('Real Usage Scenarios', () => {
|
|||
process.chdir(dataServiceDir);
|
||||
|
||||
resetConfig();
|
||||
const config = await initializeServiceConfig();
|
||||
const _config = await initializeServiceConfig();
|
||||
|
||||
// Environment variables should override file configs
|
||||
const dbConfig = getDatabaseConfig();
|
||||
|
|
@ -165,7 +165,7 @@ describe('Real Usage Scenarios', () => {
|
|||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-ingestion');
|
||||
process.chdir(dataServiceDir);
|
||||
|
||||
const config = await initializeServiceConfig();
|
||||
const _config = await initializeServiceConfig();
|
||||
|
||||
// Should throw for non-existent providers
|
||||
expect(() => getProviderConfig('nonexistent')).toThrow(
|
||||
|
|
@ -182,7 +182,7 @@ describe('Real Usage Scenarios', () => {
|
|||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-ingestion');
|
||||
process.chdir(dataServiceDir);
|
||||
|
||||
const config = await initializeServiceConfig();
|
||||
const _config = await initializeServiceConfig();
|
||||
|
||||
// Test various access patterns used in real applications
|
||||
const configManager = (await import('../src/index')).getConfigManager();
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ export class ServiceContainerBuilder {
|
|||
// Register service container aggregate
|
||||
container.register({
|
||||
serviceContainer: asFunction(({
|
||||
config, logger, cache, globalCache, proxyManager, browser,
|
||||
config: _config, logger, cache, globalCache, proxyManager, browser,
|
||||
queueManager, mongoClient, postgresClient, questdbClient
|
||||
}) => ({
|
||||
logger,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import type { ServiceDefinitions, ServiceContainerOptions } from './types';
|
|||
export function createServiceContainer(rawConfig: unknown): AwilixContainer<ServiceDefinitions> {
|
||||
// For backward compatibility, we need to create the container synchronously
|
||||
// This means we'll use the original implementation pattern
|
||||
const { createContainer, InjectionMode, asValue, asFunction, asClass } = require('awilix');
|
||||
const { createContainer, InjectionMode, asValue: _asValue, asFunction } = require('awilix');
|
||||
const { appConfigSchema } = require('../config/schemas');
|
||||
const config = appConfigSchema.parse(rawConfig);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { asClass, asFunction, asValue, type AwilixContainer } from 'awilix';
|
||||
import { createCache, type CacheProvider } from '@stock-bot/cache';
|
||||
import { asFunction, asValue, type AwilixContainer } from 'awilix';
|
||||
import type { AppConfig } from '../config/schemas';
|
||||
import type { ServiceDefinitions } from '../container/types';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { asValue, type AwilixContainer } from 'awilix';
|
||||
import { getLogger, type Logger } from '@stock-bot/logger';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { AppConfig } from '../config/schemas';
|
||||
import type { ServiceDefinitions } from '../container/types';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { asClass, asFunction, asValue, type AwilixContainer } from 'awilix';
|
|||
import { Browser } from '@stock-bot/browser';
|
||||
import { ProxyManager } from '@stock-bot/proxy';
|
||||
import { NamespacedCache } from '@stock-bot/cache';
|
||||
import type { QueueManager } from '@stock-bot/queue';
|
||||
import type { AppConfig } from '../config/schemas';
|
||||
import type { ServiceDefinitions } from '../container/types';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { createCache, type CacheProvider, type CacheStats } from '@stock-bot/cache';
|
||||
import type { RedisConfig } from './types';
|
||||
import { getServiceConfig, type ServiceConfig } from './service-registry';
|
||||
import { getServiceConfig } from './service-registry';
|
||||
|
||||
/**
|
||||
* Service-aware cache that uses the service's Redis DB
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { Queue as BullQueue, type Job } from 'bullmq';
|
||||
import IoRedis from 'ioredis';
|
||||
import { handlerRegistry } from '@stock-bot/types';
|
||||
import { getLogger, type Logger } from '@stock-bot/logger';
|
||||
import { QueueManager } from './queue-manager';
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@
|
|||
"pg-mem": "^2.8.1",
|
||||
"prettier": "^3.5.3",
|
||||
"supertest": "^6.3.4",
|
||||
"ts-unused-exports": "^11.0.1",
|
||||
"turbo": "^2.5.4",
|
||||
"typescript": "^5.8.3",
|
||||
"yup": "^1.6.1"
|
||||
|
|
|
|||
19
tsconfig.unused.json
Normal file
19
tsconfig.unused.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": [
|
||||
"apps/**/*.ts",
|
||||
"apps/**/*.tsx",
|
||||
"libs/**/*.ts",
|
||||
"libs/**/*.tsx"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"**/dist/**",
|
||||
"**/node_modules/**",
|
||||
"**/*.test.ts",
|
||||
"**/*.spec.ts",
|
||||
"**/test/**",
|
||||
"**/tests/**"
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue