From e1af73e149f6af6ca60bab74605bdad49a7947f6 Mon Sep 17 00:00:00 2001 From: Charles Dufour Date: Tue, 13 Aug 2024 18:15:20 +0200 Subject: [PATCH] [TRELLO-2496] Add minimized anomalies endpoint (#872) * [TRELLO-2496] Add minimized anomalies endpoint * [TRELLO-2496] Format --- .../src/controllers/categories.controller.ts | 13 ++++++++++++- mobile-tools/src/services/categories.service.ts | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mobile-tools/src/controllers/categories.controller.ts b/mobile-tools/src/controllers/categories.controller.ts index c9bf3344e..c7d45aaac 100644 --- a/mobile-tools/src/controllers/categories.controller.ts +++ b/mobile-tools/src/controllers/categories.controller.ts @@ -1,5 +1,5 @@ import {Request, Router} from 'express' -import {categories} from '../services/categories.service.js' +import {categories, minimizedAnomaliesEn, minimizedAnomaliesFr} from '../services/categories.service.js' interface QueryParams { lang?: 'fr' | 'en' @@ -16,4 +16,15 @@ CategoriesController.get('/', async (req: Request<{}, {}, {}, QueryParams>, res, } }) +CategoriesController.get('/minimized', async (req: Request<{}, {}, {}>, res, next) => { + try { + return res.status(200).send({ + fr: minimizedAnomaliesFr, + en: minimizedAnomaliesEn, + }) + } catch (err) { + next(err) + } +}) + export {CategoriesController} diff --git a/mobile-tools/src/services/categories.service.ts b/mobile-tools/src/services/categories.service.ts index 4a80770af..3a4e924bd 100644 --- a/mobile-tools/src/services/categories.service.ts +++ b/mobile-tools/src/services/categories.service.ts @@ -9,6 +9,9 @@ export interface Category { const anomaliesFr = JSON.parse(fs.readFileSync('../shared/anomalies/json/anomalies_fr.json', 'utf-8')) const anomaliesEn = JSON.parse(fs.readFileSync('../shared/anomalies/json/anomalies_en.json', 'utf-8')) +export const minimizedAnomaliesFr = JSON.parse(fs.readFileSync('../shared/anomalies/json/minimized-anomalies_fr.json', 'utf-8')) +export const minimizedAnomaliesEn = JSON.parse(fs.readFileSync('../shared/anomalies/json/minimized-anomalies_en.json', 'utf-8')) + const categoriesFr: Category[] = anomaliesFr.map((anomaly: any) => { return { category: anomaly.category,