Skip to content

Commit

Permalink
[TRELLO-2496] Add minimized anomalies endpoint (#872)
Browse files Browse the repository at this point in the history
* [TRELLO-2496] Add minimized anomalies endpoint

* [TRELLO-2496] Format
  • Loading branch information
charlescd authored Aug 13, 2024
1 parent d727fec commit e1af73e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 12 additions & 1 deletion mobile-tools/src/controllers/categories.controller.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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}
3 changes: 3 additions & 0 deletions mobile-tools/src/services/categories.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e1af73e

Please sign in to comment.