-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #428 from dnum-mi/tech/harmonize-api-logs
refactor: 🔊 harmonize api logs
- Loading branch information
Showing
23 changed files
with
798 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
import { getAllProjects } from '../models/queries/project-queries.js' | ||
import { getLogInfos } from '../utils/logger.js' | ||
import { sendOk, sendNotFound } from '../utils/response.js' | ||
import { addReqLogs } from '../../utils/logger.js' | ||
import { getAllProjects } from '../../models/queries/project-queries.js' | ||
import { sendOk, sendNotFound } from '../../utils/response.js' | ||
import { adminGroupPath } from 'shared/src/utils/const.js' | ||
|
||
export const getAllProjectsController = async (req, res) => { | ||
try { | ||
if (!req.session.user.groups?.includes(adminGroupPath)) throw new Error('Vous n\'avez pas les droits administrateurs') | ||
if (!req.session.user.groups?.includes(adminGroupPath)) throw new Error('Vous n\'avez pas les droits administrateur') | ||
const projects = await getAllProjects() | ||
req.log.info({ | ||
...getLogInfos(), | ||
description: 'Projects récupérés avec succès', | ||
addReqLogs({ | ||
req, | ||
description: 'Ensemble des projets récupérés avec succès', | ||
}) | ||
return sendOk(res, projects) | ||
} catch (error) { | ||
const message = 'Projets non trouvés' | ||
req.log.error({ | ||
...getLogInfos(), | ||
description: message, | ||
error: error.message, | ||
const description = 'Echec de la récupération de l\'ensemble des projets' | ||
addReqLogs({ | ||
req, | ||
description, | ||
error, | ||
}) | ||
sendNotFound(res, message) | ||
sendNotFound(res, description) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.