ffffng/server/resources/statisticsResource.ts
baldo 250353edbf Major refactoring and fixes.
* Split Node into multiple types and make sure fields are actually set
  when type says so.
* Refactor request handling.
* Start getting rid of moment as a dependency by using
  UnixTimestampSeconds instead.
2022-07-21 18:39:33 +02:00

17 lines
540 B
TypeScript

import ErrorTypes from "../utils/errorTypes";
import Logger from "../logger";
import {getNodeStatistics} from "../services/nodeService";
import {handleJSON} from "../utils/resources";
export const get = handleJSON(async () => {
try {
const nodeStatistics = await getNodeStatistics();
return {
nodes: nodeStatistics
};
} catch (error) {
Logger.tag('statistics').error('Error getting statistics:', error);
throw {data: 'Internal error.', type: ErrorTypes.internalError};
}
});