reorg to domain and api
This commit is contained in:
1 parent
0fb210e9e1
commit
d022f7d849
190 files changed
+643
-830
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { IStatusProvider } from "@/service/network/IStatusProvider.js";
|
||||
import { HardwareStatusPayload, MonitorStatusResponse } from "@/types/network.js";
|
||||
import { Monitor, MonitorType } from "@/domain/monitors/monitor.types.js";
|
||||
import { HttpProvider } from "@/service/network/HttpProvider.js";
|
||||
import { AppError } from "@/utils/AppError.js";
|
||||
|
||||
export class HardwareProvider implements IStatusProvider<HardwareStatusPayload> {
|
||||
readonly type = "hardware";
|
||||
constructor(private httpProvider: HttpProvider) {}
|
||||
|
||||
supports(type: MonitorType) {
|
||||
return type === "hardware";
|
||||
}
|
||||
|
||||
async handle(monitor: Monitor): Promise<MonitorStatusResponse<HardwareStatusPayload>> {
|
||||
const { url } = monitor;
|
||||
try {
|
||||
if (!url) throw new Error("URL is required for Hardware monitor");
|
||||
return await this.httpProvider.handle<HardwareStatusPayload>(monitor);
|
||||
} catch (err: unknown) {
|
||||
throw new AppError({
|
||||
message: err instanceof Error ? err.message : "Error performing Hardware request",
|
||||
service: "HardwareProvider",
|
||||
method: "handle",
|
||||
details: { url: monitor.url },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user