ffffng/server/resources/statisticsResource.ts

20 lines
673 B
TypeScript
Raw Normal View History

import ErrorTypes from "../utils/errorTypes";
import Logger from "../logger";
import {getNodeStatistics} from "../services/nodeService";
import * as Resources from "../utils/resources";
import {Request, Response} from "express";
export function get (req: Request, res: Response): void {
getNodeStatistics()
.then(nodeStatistics => Resources.success(
res,
{
nodes: nodeStatistics
}
))
.catch(err => {
Logger.tag('statistics').error('Error getting statistics:', err);
return Resources.error(res, {data: 'Internal error.', type: ErrorTypes.internalError});
});
}