feat: add sessions stats endpoint

This commit is contained in:
Carlos Valente
2024-10-20 22:19:33 +02:00
committed by Carlos Valente
parent 71c468d069
commit 82810f1cb1
8 changed files with 71 additions and 3 deletions
@@ -1,10 +1,20 @@
import { getErrorMessage } from 'ontime-utils';
import { ErrorResponse, GetInfo } from 'ontime-types';
import { ErrorResponse, GetInfo, SessionStats } from 'ontime-types';
import type { Request, Response } from 'express';
import * as sessionService from './session.service.js';
export async function getSessionStats(_req: Request, res: Response<SessionStats | ErrorResponse>) {
try {
const stats = await sessionService.getSessionStats();
res.status(200).send(stats);
} catch (error) {
const message = getErrorMessage(error);
res.status(500).send({ message });
}
}
export async function getInfo(_req: Request, res: Response<GetInfo | ErrorResponse>) {
try {
const info = await sessionService.getInfo();