diff --git a/apps/client/src/common/api/apiUtils.ts b/apps/client/src/common/api/apiUtils.ts index 4042761bb..4388980df 100644 --- a/apps/client/src/common/api/apiUtils.ts +++ b/apps/client/src/common/api/apiUtils.ts @@ -11,7 +11,6 @@ export function maybeAxiosError(error: unknown) { const statusText = (error as AxiosError).response?.statusText ?? ''; let data = (error as AxiosError).response?.data ?? ''; if (typeof data === 'object') { - // TODO: use error instead, when migrated if ('message' in data) { data = JSON.stringify(data.message); } else { diff --git a/apps/client/src/common/hooks/useEventAction.ts b/apps/client/src/common/hooks/useEventAction.ts index 1cb8af577..7bd9ff7c4 100644 --- a/apps/client/src/common/hooks/useEventAction.ts +++ b/apps/client/src/common/hooks/useEventAction.ts @@ -100,7 +100,7 @@ export const useEventAction = () => { // @ts-expect-error -- we know that the object is well formed now await _addEventMutation.mutateAsync(newEvent); } catch (error) { - logAxiosError('Error fetching data', error); + logAxiosError('Failed adding event', error); } }, [_addEventMutation, defaultPublic, queryClient, startTimeIsLastEnd], diff --git a/apps/server/src/classes/data-provider/DataProvider.ts b/apps/server/src/classes/data-provider/DataProvider.ts index ea5285b9b..031a537d5 100644 --- a/apps/server/src/classes/data-provider/DataProvider.ts +++ b/apps/server/src/classes/data-provider/DataProvider.ts @@ -46,7 +46,6 @@ export class DataProvider { static async clearRundown() { data.rundown = []; - // @ts-expect-error -- not sure how to type, this is library side await db.write(); } @@ -100,7 +99,6 @@ export class DataProvider { } static async persist() { - // @ts-expect-error -- not sure how to type, this is library side await db.write(); } diff --git a/apps/server/src/controllers/ontimeController.ts b/apps/server/src/controllers/ontimeController.ts index 76eca8aea..d481e245a 100644 --- a/apps/server/src/controllers/ontimeController.ts +++ b/apps/server/src/controllers/ontimeController.ts @@ -149,7 +149,7 @@ export const postAliases = async (req, res) => { await DataProvider.setAliases(newAliases); res.status(200).send(newAliases); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; @@ -172,7 +172,7 @@ export const postUserFields = async (req, res) => { await DataProvider.setUserFields(newData); res.status(200).send(newData); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; @@ -235,7 +235,7 @@ export const postSettings = async (req, res) => { await DataProvider.setSettings(newData); res.status(200).send(newData); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; @@ -270,7 +270,7 @@ export const postViewSettings = async (req, res) => { await DataProvider.setViewSettings(newData); res.status(200).send(newData); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; @@ -298,7 +298,7 @@ export const postOscSubscriptions = async (req, res) => { res.send(oscSettings).status(200); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; @@ -319,7 +319,7 @@ export const postOSC = async (req, res) => { res.send(oscSettings).status(200); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; @@ -348,7 +348,7 @@ export async function patchPartialProjectFile(req, res) { } res.status(200).send(); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } } @@ -409,6 +409,6 @@ export const postNew: RequestHandler = async (req, res) => { await deleteAllEvents(); res.status(201).send(newData); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; diff --git a/apps/server/src/controllers/playbackController.ts b/apps/server/src/controllers/playbackController.ts index fe71f19c1..fa1fc80e8 100644 --- a/apps/server/src/controllers/playbackController.ts +++ b/apps/server/src/controllers/playbackController.ts @@ -13,14 +13,14 @@ export const pbStart = async (req, res) => { const { eventId, eventIndex } = req.query; if (eventId) { const success = PlaybackService.startById(eventId); - success ? res.sendStatus(202) : res.status(400).send('Invalid event ID'); + success ? res.sendStatus(202) : res.status(400).send({ message: 'Invalid event ID' }); } else if (eventIndex) { const index = Number(eventIndex); if (!isNaN(index)) { const success = PlaybackService.startByIndex(eventIndex - 1); - success ? res.sendStatus(202) : res.status(400).send('Invalid event index'); + success ? res.sendStatus(202) : res.status(400).send({ message: 'Invalid event index' }); } else { - res.status(400).send('Invalid event index'); + res.status(400).send({ message: 'Invalid event index' }); } } else { PlaybackService.start(); @@ -69,17 +69,17 @@ export const pbLoad = async (req, res) => { const { eventId, eventIndex } = req.query; if (eventId) { const success = PlaybackService.loadById(eventId); - success ? res.sendStatus(202) : res.status(400).send('Invalid event ID'); + success ? res.sendStatus(202) : res.status(400).send({ message: 'Invalid event ID' }); } else if (eventIndex) { const index = Number(eventIndex); if (!isNaN(index)) { const success = PlaybackService.loadByIndex(eventIndex - 1); - success ? res.sendStatus(202) : res.status(400).send('Invalid event index'); + success ? res.sendStatus(202) : res.status(400).send({ message: 'Invalid event index' }); } else { - res.status(400).send('Invalid event index'); + res.status(400).send({ message: 'Invalid event index' }); } } else { - res.status(400).send('No event given'); + res.status(400).send({ message: 'No event given' }); } }; diff --git a/apps/server/src/controllers/projectController.ts b/apps/server/src/controllers/projectController.ts index c9f6e8d0e..095cc2702 100644 --- a/apps/server/src/controllers/projectController.ts +++ b/apps/server/src/controllers/projectController.ts @@ -30,6 +30,6 @@ export const postProject: RequestHandler = async (req, res) => { const newData = await DataProvider.setProjectData(newEvent); res.status(200).send(newData); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; diff --git a/apps/server/src/controllers/rundownController.ts b/apps/server/src/controllers/rundownController.ts index c2a00231a..e0e55e357 100644 --- a/apps/server/src/controllers/rundownController.ts +++ b/apps/server/src/controllers/rundownController.ts @@ -29,7 +29,7 @@ export const rundownPost: RequestHandler = async (req, res) => { const newEvent = await addEvent(req.body); res.status(201).send(newEvent); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; @@ -44,7 +44,7 @@ export const rundownPut: RequestHandler = async (req, res) => { const event = await editEvent(req.body); res.status(200).send(event); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; @@ -58,7 +58,7 @@ export const rundownReorder: RequestHandler = async (req, res) => { const event = await reorderEvent(eventId, from, to); res.status(200).send(event); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; @@ -72,7 +72,7 @@ export const rundownSwap: RequestHandler = async (req, res) => { await swapEvents(from, to); res.sendStatus(200); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; @@ -83,7 +83,7 @@ export const rundownApplyDelay: RequestHandler = async (req, res) => { await applyDelay(req.params.eventId); res.sendStatus(200); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; @@ -94,7 +94,7 @@ export const deleteEventById: RequestHandler = async (req, res) => { await deleteEvent(req.params.eventId); res.sendStatus(204); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; @@ -105,6 +105,6 @@ export const rundownDelete: RequestHandler = async (req, res) => { await deleteAllEvents(); res.sendStatus(204); } catch (error) { - res.status(400).send(error); + res.status(400).send({ message: error.toString() }); } }; diff --git a/apps/server/src/modules/loadDb.ts b/apps/server/src/modules/loadDb.ts index 4b831f131..9442b1228 100644 --- a/apps/server/src/modules/loadDb.ts +++ b/apps/server/src/modules/loadDb.ts @@ -67,7 +67,7 @@ async function loadDb() { return { db, data }; } -export let db = {}; +export let db = {} as Low; export let data = {} as DatabaseModel; export const dbLoadingProcess = loadDb(); diff --git a/apps/server/src/services/rundown-service/RundownService.ts b/apps/server/src/services/rundown-service/RundownService.ts index 8da7f6642..e2efb97d0 100644 --- a/apps/server/src/services/rundown-service/RundownService.ts +++ b/apps/server/src/services/rundown-service/RundownService.ts @@ -158,7 +158,7 @@ export function updateTimer(affectedIds?: string[]) { export async function addEvent(eventData: Partial | Partial | Partial) { const numEvents = DataProvider.getRundownLength(); if (numEvents > MAX_EVENTS) { - throw new Error(`ERROR: Reached limit number of ${MAX_EVENTS} events`); + throw new Error(`Reached limit number of ${MAX_EVENTS} events`); } let newEvent: Partial = {};