Skip to content

Commit c014d30

Browse files
committed
chore: fix type on docker event
1 parent 1c9c77e commit c014d30

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

api/src/unraid-api/graph/resolvers/docker/docker-event.service.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ enum DockerEventType {
2525
CONTAINER = 'container',
2626
}
2727

28+
interface DockerEvent {
29+
Action?: string;
30+
status?: string;
31+
from?: string;
32+
Type?: string;
33+
[key: string]: unknown;
34+
}
35+
2836
@Injectable()
2937
export class DockerEventService implements OnModuleDestroy, OnModuleInit {
3038
private client: Docker;
@@ -96,18 +104,28 @@ export class DockerEventService implements OnModuleDestroy, OnModuleInit {
96104
}
97105
}
98106

99-
private async handleDockerEvent(event: any): Promise<void> {
107+
private async handleDockerEvent(event: unknown): Promise<void> {
108+
if (typeof event !== 'object' || event === null) {
109+
this.logger.error('Received non-object event', event);
110+
return;
111+
}
112+
113+
// Type assertion to DockerEvent
114+
const dockerEvent = event as DockerEvent;
115+
100116
// Check if this is an action we're watching
101-
const actionName = event.Action || event.status;
117+
const actionName = dockerEvent.Action || dockerEvent.status;
102118
const shouldProcess = this.watchedActions.some(
103119
(action) => typeof actionName === 'string' && actionName.startsWith(action)
104120
);
105121

106122
if (shouldProcess) {
107-
this.logger.debug(`[${event.from}] ${event.Type}->${actionName}`);
123+
this.logger.debug(`[${dockerEvent.from}] ${dockerEvent.Type}->${actionName}`);
108124

109125
// For container lifecycle events, update the container cache
110-
if (event.Type === DockerEventType.CONTAINER && this.containerActions.includes(actionName)) {
126+
if (dockerEvent.Type === DockerEventType.CONTAINER &&
127+
typeof actionName === 'string' &&
128+
this.containerActions.includes(actionName as DockerEventAction)) {
111129
await this.dockerService.debouncedContainerCacheUpdate();
112130
}
113131
}

0 commit comments

Comments
 (0)