mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-28 01:10:54 +01:00
* feat: add simple ping * refactor: make ping run on server and show errors * fix: format issues * fix: missing translation for enabled ping option for app * refactor: remove ping queue as no longer needed * chore: address pull request feedback * test: add some unit tests * fix: format issues * fix: deepsource issues
26 lines
675 B
TypeScript
26 lines
675 B
TypeScript
"use server";
|
|
|
|
import type { RouterOutputs } from "@homarr/api";
|
|
import { api } from "@homarr/api/server";
|
|
|
|
import type { WidgetProps } from "../definition";
|
|
|
|
export default async function getServerDataAsync({ options }: WidgetProps<"app">) {
|
|
if (!options.appId) {
|
|
return { app: null, pingResult: null };
|
|
}
|
|
|
|
try {
|
|
const app = await api.app.byId({ id: options.appId });
|
|
let pingResult: RouterOutputs["widget"]["app"]["ping"] | null = null;
|
|
|
|
if (app.href && options.pingEnabled) {
|
|
pingResult = await api.widget.app.ping({ url: app.href });
|
|
}
|
|
|
|
return { app, pingResult };
|
|
} catch (error) {
|
|
return { app: null, pingResult: null };
|
|
}
|
|
}
|