cleanup imports
This commit is contained in:
1 parent
432d1d8ccf
commit
89a7fdbe34
4 files changed
+53
-65
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import { HTTPError, RequestError } from "got";
|
||||
import type { Got, Response } from "got";
|
||||
import type { Monitor, MonitorStatusResponse } from "@/types/index.js";
|
||||
import type { AxiosStatic } from "axios";
|
||||
import type Docker from "dockerode";
|
||||
|
||||
import CacheableLookup from "cacheable-lookup";
|
||||
import { ISettingsService } from "../system/settingsService.js";
|
||||
@@ -48,16 +50,16 @@ class NetworkService implements INetworkService {
|
||||
private NETWORK_ERROR: number;
|
||||
private PING_ERROR: number;
|
||||
|
||||
private axios: any;
|
||||
private axios: AxiosStatic;
|
||||
private got: Got;
|
||||
private https: any;
|
||||
private jmespath: any;
|
||||
private GameDig: any;
|
||||
private ping: any;
|
||||
private logger: any;
|
||||
private logger: ILogger;
|
||||
private Docker: any;
|
||||
private net: any;
|
||||
private settingsService: any;
|
||||
private settingsService: ISettingsService;
|
||||
|
||||
private buildStatusResponse = <T>({
|
||||
monitor,
|
||||
@@ -114,7 +116,7 @@ class NetworkService implements INetworkService {
|
||||
};
|
||||
|
||||
constructor(
|
||||
axios: any,
|
||||
axios: AxiosStatic,
|
||||
got: Got,
|
||||
https: any,
|
||||
jmespath: any,
|
||||
@@ -423,7 +425,6 @@ class NetworkService implements INetworkService {
|
||||
|
||||
const docker = new this.Docker({
|
||||
socketPath: "/var/run/docker.sock",
|
||||
handleError: true, // Enable error handling
|
||||
});
|
||||
|
||||
const dockerResponse = this.buildStatusResponse({
|
||||
@@ -519,6 +520,10 @@ class NetworkService implements INetworkService {
|
||||
private async requestPort(monitor: Monitor): Promise<MonitorStatusResponse> {
|
||||
try {
|
||||
const { url, port } = monitor;
|
||||
if (!port) {
|
||||
throw new Error("Port is required for port monitor");
|
||||
}
|
||||
|
||||
const { response, responseTime, error } = await this.timeRequest(async () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const socket = this.net.createConnection(
|
||||
@@ -585,9 +590,9 @@ class NetworkService implements INetworkService {
|
||||
});
|
||||
|
||||
const state = await this.GameDig.query({
|
||||
type: gameId,
|
||||
type: gameId ?? "unknown",
|
||||
host: url,
|
||||
port: port,
|
||||
port: port ?? 0,
|
||||
}).catch((error: any) => {
|
||||
this.logger.warn({
|
||||
message: error.message,
|
||||
|
||||
Reference in new issue
Block a user