2020-04-10 00:43:15 +02:00
|
|
|
import ErrorTypes from "../utils/errorTypes";
|
|
|
|
import Logger from "../logger";
|
2022-08-23 20:08:53 +02:00
|
|
|
import { getNodeStatistics } from "../services/nodeService";
|
|
|
|
import { handleJSON } from "../utils/resources";
|
2020-04-10 00:43:15 +02:00
|
|
|
|
2022-07-21 18:39:33 +02:00
|
|
|
export const get = handleJSON(async () => {
|
|
|
|
try {
|
|
|
|
const nodeStatistics = await getNodeStatistics();
|
|
|
|
return {
|
2022-08-23 20:08:53 +02:00
|
|
|
nodes: nodeStatistics,
|
2022-07-21 18:39:33 +02:00
|
|
|
};
|
|
|
|
} catch (error) {
|
2022-08-23 20:08:53 +02:00
|
|
|
Logger.tag("statistics").error("Error getting statistics:", error);
|
|
|
|
throw { data: "Internal error.", type: ErrorTypes.internalError };
|
2022-07-21 18:39:33 +02:00
|
|
|
}
|
|
|
|
});
|