From 733e0b89f372e5e3113fed24d617f1c250b35f87 Mon Sep 17 00:00:00 2001 From: Nico Hagelberg <16757571+nicou@users.noreply.github.com> Date: Sun, 30 Jun 2024 19:46:20 +0300 Subject: [PATCH] Non-critical improvements (#62) * Log data blob type and id on version conflict * Use a different color for debug logs * Add another WORM-1 UID mapping --- db/redux/misc/index.ts | 1 + src/logger.ts | 13 ++++++++++++- src/routes/data.js | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/db/redux/misc/index.ts b/db/redux/misc/index.ts index 8977eab7..bb7a97b4 100644 --- a/db/redux/misc/index.ts +++ b/db/redux/misc/index.ts @@ -101,6 +101,7 @@ const blobs: unknown[] = [ '0410948A2A6280': 'JW2888', '040C948A2A6280': 'VE-342', '0408938A2A6280': 'WORM-1', + '0489938A2A6280': 'WORM-1', }, }, { diff --git a/src/logger.ts b/src/logger.ts index 84fef892..66a709a4 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -1,5 +1,16 @@ import { Request, Response, NextFunction } from 'express'; -import logger from 'signale'; +import { Signale } from 'signale'; + +const logger = new Signale({ + types: { + // Override the default debug logger to not be so intimidating + debug: { + badge: 'i', + color: 'cyan', + label: 'debug', + }, + }, +}); const loggerMiddleware = (req: Request, res: Response, next: NextFunction) => { next(); diff --git a/src/routes/data.js b/src/routes/data.js index 427eaa2b..713071ef 100644 --- a/src/routes/data.js +++ b/src/routes/data.js @@ -18,7 +18,7 @@ export function setData(dataType, dataId, data, force = false) { if (!force) { const oldData = getData(dataType, dataId); if (oldData.version && oldData.version !== data.version) { - throw new httpErrors.Conflict(`Wrong version number, provided '${data.version}', expected '${oldData.version}'`); + throw new httpErrors.Conflict(`Wrong version number for ${dataType}/${dataId}, provided '${data.version}', expected '${oldData.version}'`); } }