-
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.
- Loading branch information
ArnaudTA
committed
Jun 5, 2023
1 parent
c346f6e
commit 17985ff
Showing
3 changed files
with
28 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { adminGroupPath } from 'shared/src/utils/const.js' | ||
import { sendForbidden, sendNotFound, sendOk } from '../../utils/response.js' | ||
import { getAllLogs } from '../../models/queries/log-queries.js' | ||
|
||
export const getLogsController = async (req, res) => { | ||
if (!req.session.user.groups?.includes(adminGroupPath)) sendForbidden(res, 'Vous n\'avez pas les droits administrateur') | ||
|
||
try { | ||
const logs = await getAllLogs() | ||
|
||
sendOk(res, logs) | ||
} catch (error) { | ||
const description = 'Echec de la récupération des organisations' | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import userRouter from './user.js' | ||
import organizationRouter from './organization.js' | ||
import logRouter from './log.js' | ||
|
||
const router = async (app, _opt) => { | ||
// Enregistrement du sous routeur user | ||
await app.register(userRouter, { prefix: '/users' }) | ||
|
||
// Enregistrement du sous routeur organization | ||
await app.register(organizationRouter, { prefix: '/organizations' }) | ||
|
||
// Enregistrement du sous routeur logd | ||
await app.register(logRouter, { prefix: '/log' }) | ||
} | ||
|
||
export default router |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { getLogsController } from '../../controllers/admin/logs.js' | ||
|
||
const router = async (app, _opt) => { | ||
// Récupérer toutes les organisations | ||
await app.get('/', getLogsController) | ||
} | ||
|
||
export default router |