Skip to content

Commit 0a8e8f1

Browse files
committed
style(backend): apply ESLint fixes and remove unused code
- Fix build script to ensure dist/database directory exists - Apply consistent code formatting (quotes, line breaks) - Remove unused variables and parameters - Remove unused imports - Improve code readability and maintainability
1 parent a4550f8 commit 0a8e8f1

File tree

5 files changed

+54
-25
lines changed

5 files changed

+54
-25
lines changed

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "dist/server.js",
66
"scripts": {
77
"dev": "tsx watch src/server.ts",
8-
"build": "tsc && cp src/database/schema.sql dist/database/ && cp src/database/migrations.sql dist/database/",
8+
"build": "tsc && mkdir -p dist/database && cp src/database/schema.sql dist/database/ && cp src/database/migrations.sql dist/database/",
99
"start": "node dist/server.js",
1010
"test": "vitest --run",
1111
"test:watch": "vitest",

backend/src/config/ConfigService.ts

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { config as loadDotenv } from 'dotenv';
2-
import { AppConfigSchema, type AppConfig, type WhitelistConfig, type StreamingConfig } from './schema';
3-
import { z } from 'zod';
1+
import { config as loadDotenv } from "dotenv";
2+
import {
3+
AppConfigSchema,
4+
type AppConfig,
5+
type WhitelistConfig,
6+
} from "./schema";
7+
import { z } from "zod";
48

59
/**
610
* Configuration service to load and validate application settings
@@ -25,19 +29,26 @@ export class ConfigService {
2529
// Parse command whitelist from JSON string
2630
let commandWhitelist: WhitelistConfig;
2731
try {
28-
const whitelistJson = process.env.COMMAND_WHITELIST ?? '[]';
32+
const whitelistJson = process.env.COMMAND_WHITELIST ?? "[]";
2933
const parsedWhitelist: unknown = JSON.parse(whitelistJson);
3034
const whitelistArray: string[] = Array.isArray(parsedWhitelist)
31-
? parsedWhitelist.filter((item): item is string => typeof item === 'string')
35+
? parsedWhitelist.filter(
36+
(item): item is string => typeof item === "string",
37+
)
3238
: [];
3339
const matchMode = process.env.COMMAND_WHITELIST_MATCH_MODE;
3440
commandWhitelist = {
35-
allowAll: process.env.COMMAND_WHITELIST_ALLOW_ALL === 'true',
41+
allowAll: process.env.COMMAND_WHITELIST_ALLOW_ALL === "true",
3642
whitelist: whitelistArray,
37-
matchMode: (matchMode === 'exact' || matchMode === 'prefix') ? matchMode : 'exact',
43+
matchMode:
44+
matchMode === "exact" || matchMode === "prefix"
45+
? matchMode
46+
: "exact",
3847
};
3948
} catch (error) {
40-
throw new Error(`Failed to parse COMMAND_WHITELIST: ${error instanceof Error ? error.message : 'Unknown error'}`);
49+
throw new Error(
50+
`Failed to parse COMMAND_WHITELIST: ${error instanceof Error ? error.message : "Unknown error"}`,
51+
);
4152
}
4253

4354
// Parse package tasks from JSON string if provided
@@ -46,27 +57,43 @@ export class ConfigService {
4657
try {
4758
packageTasks = JSON.parse(process.env.PACKAGE_TASKS);
4859
} catch (error) {
49-
throw new Error(`Failed to parse PACKAGE_TASKS: ${error instanceof Error ? error.message : 'Unknown error'}`);
60+
throw new Error(
61+
`Failed to parse PACKAGE_TASKS: ${error instanceof Error ? error.message : "Unknown error"}`,
62+
);
5063
}
5164
}
5265

5366
// Parse streaming configuration
5467
const streaming = {
55-
bufferMs: process.env.STREAMING_BUFFER_MS ? parseInt(process.env.STREAMING_BUFFER_MS, 10) : undefined,
56-
maxOutputSize: process.env.STREAMING_MAX_OUTPUT_SIZE ? parseInt(process.env.STREAMING_MAX_OUTPUT_SIZE, 10) : undefined,
57-
maxLineLength: process.env.STREAMING_MAX_LINE_LENGTH ? parseInt(process.env.STREAMING_MAX_LINE_LENGTH, 10) : undefined,
68+
bufferMs: process.env.STREAMING_BUFFER_MS
69+
? parseInt(process.env.STREAMING_BUFFER_MS, 10)
70+
: undefined,
71+
maxOutputSize: process.env.STREAMING_MAX_OUTPUT_SIZE
72+
? parseInt(process.env.STREAMING_MAX_OUTPUT_SIZE, 10)
73+
: undefined,
74+
maxLineLength: process.env.STREAMING_MAX_LINE_LENGTH
75+
? parseInt(process.env.STREAMING_MAX_LINE_LENGTH, 10)
76+
: undefined,
5877
};
5978

6079
// Parse cache configuration
6180
const cache = {
62-
inventoryTtl: process.env.CACHE_INVENTORY_TTL ? parseInt(process.env.CACHE_INVENTORY_TTL, 10) : undefined,
63-
factsTtl: process.env.CACHE_FACTS_TTL ? parseInt(process.env.CACHE_FACTS_TTL, 10) : undefined,
81+
inventoryTtl: process.env.CACHE_INVENTORY_TTL
82+
? parseInt(process.env.CACHE_INVENTORY_TTL, 10)
83+
: undefined,
84+
factsTtl: process.env.CACHE_FACTS_TTL
85+
? parseInt(process.env.CACHE_FACTS_TTL, 10)
86+
: undefined,
6487
};
6588

6689
// Parse execution queue configuration
6790
const executionQueue = {
68-
concurrentLimit: process.env.CONCURRENT_EXECUTION_LIMIT ? parseInt(process.env.CONCURRENT_EXECUTION_LIMIT, 10) : undefined,
69-
maxQueueSize: process.env.MAX_QUEUE_SIZE ? parseInt(process.env.MAX_QUEUE_SIZE, 10) : undefined,
91+
concurrentLimit: process.env.CONCURRENT_EXECUTION_LIMIT
92+
? parseInt(process.env.CONCURRENT_EXECUTION_LIMIT, 10)
93+
: undefined,
94+
maxQueueSize: process.env.MAX_QUEUE_SIZE
95+
? parseInt(process.env.MAX_QUEUE_SIZE, 10)
96+
: undefined,
7097
};
7198

7299
// Build configuration object
@@ -75,7 +102,9 @@ export class ConfigService {
75102
host: process.env.HOST,
76103
boltProjectPath: process.env.BOLT_PROJECT_PATH,
77104
commandWhitelist,
78-
executionTimeout: process.env.EXECUTION_TIMEOUT ? parseInt(process.env.EXECUTION_TIMEOUT, 10) : undefined,
105+
executionTimeout: process.env.EXECUTION_TIMEOUT
106+
? parseInt(process.env.EXECUTION_TIMEOUT, 10)
107+
: undefined,
79108
logLevel: process.env.LOG_LEVEL,
80109
databasePath: process.env.DATABASE_PATH,
81110
packageTasks,
@@ -88,7 +117,9 @@ export class ConfigService {
88117
return AppConfigSchema.parse(rawConfig);
89118
} catch (error) {
90119
if (error instanceof z.ZodError) {
91-
const issues = error.issues.map(issue => `${issue.path.join('.')}: ${issue.message}`).join(', ');
120+
const issues = error.issues
121+
.map((issue) => `${issue.path.join(".")}: ${issue.message}`)
122+
.join(", ");
92123
throw new Error(`Configuration validation failed: ${issues}`);
93124
}
94125
throw error;

backend/src/routes/executions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export function createExecutionsRouter(
141141
* GET /api/executions/queue/status
142142
* Return current execution queue status
143143
*/
144-
router.get('/queue/status', asyncHandler(async (req: Request, res: Response): Promise<void> => {
144+
router.get('/queue/status', asyncHandler(async (_req: Request, res: Response): Promise<void> => {
145145
if (!executionQueue) {
146146
res.status(503).json({
147147
error: {

backend/src/services/ExecutionQueue.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class ExecutionQueue {
119119
// Sort by enqueued time (oldest first)
120120
entries.sort((a, b) => a[1].enqueuedAt.getTime() - b[1].enqueuedAt.getTime());
121121

122-
const [executionId, execution] = entries[0];
122+
const [executionId] = entries[0];
123123

124124
// Move from queue to running
125125
this.queuedExecutions.delete(executionId);
@@ -140,8 +140,7 @@ export class ExecutionQueue {
140140
* @returns true if execution was cancelled, false if not found or already running
141141
*/
142142
public cancel(executionId: string): boolean {
143-
const execution = this.queuedExecutions.get(executionId);
144-
if (!execution) {
143+
if (!this.queuedExecutions.has(executionId)) {
145144
return false;
146145
}
147146

@@ -216,7 +215,7 @@ export class ExecutionQueue {
216215
*/
217216
public clearQueue(): void {
218217
// Reject all waiting promises
219-
for (const [executionId, promise] of this.waitingPromises.entries()) {
218+
for (const promise of this.waitingPromises.values()) {
220219
promise.reject(new Error('Queue cleared'));
221220
}
222221

backend/test/database/ExecutionRepository.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, afterEach } from "vitest";
22
import sqlite3 from "sqlite3";
33
import {
44
ExecutionRepository,
5-
ExecutionRecord,
65
ExecutionType,
76
ExecutionStatus,
87
} from "../../src/database/ExecutionRepository";

0 commit comments

Comments
 (0)