mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-07 08:23:55 +00:00
refactor: small cleanups (#2059)
* refactor: remove unneeded async * chore: add express Router type to all routes * refactor: don't use index in react key * refactor: correctly get error message in excel route * refactor: avoid exporting muteable values
This commit is contained in:
committed by
GitHub
parent
23a44b2f04
commit
7c1d2f4554
@@ -1,12 +1,12 @@
|
||||
import express from 'express';
|
||||
import type { Request, Response } from 'express';
|
||||
import type { Request, Response, Router } from 'express';
|
||||
import type { ErrorResponse, GetInfo, GetUrl, SessionStats } from 'ontime-types';
|
||||
import { getErrorMessage } from 'ontime-utils';
|
||||
|
||||
import * as sessionService from './session.service.js';
|
||||
import { validateGenerateUrl } from './session.validation.js';
|
||||
|
||||
export const router = express.Router();
|
||||
export const router: Router = express.Router();
|
||||
|
||||
router.get('/', async (_req: Request, res: Response<SessionStats | ErrorResponse>) => {
|
||||
try {
|
||||
@@ -18,9 +18,9 @@ router.get('/', async (_req: Request, res: Response<SessionStats | ErrorResponse
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/info', async (_req: Request, res: Response<GetInfo | ErrorResponse>) => {
|
||||
router.get('/info', (_req: Request, res: Response<GetInfo | ErrorResponse>) => {
|
||||
try {
|
||||
const info = await sessionService.getInfo();
|
||||
const info = sessionService.getInfo();
|
||||
res.status(200).send(info);
|
||||
} catch (error) {
|
||||
const message = getErrorMessage(error);
|
||||
|
||||
@@ -37,7 +37,7 @@ export async function getSessionStats(): Promise<SessionStats> {
|
||||
/**
|
||||
* Adds business logic to gathering data for the info endpoint
|
||||
*/
|
||||
export async function getInfo(): Promise<GetInfo> {
|
||||
export function getInfo(): GetInfo {
|
||||
const { version } = getDataProvider().getSettings();
|
||||
const { port } = portManager.getPort();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user