Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/log endpoint #435

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/server/src/controllers/admin/logs.js
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)
}
}
4 changes: 4 additions & 0 deletions apps/server/src/routes/admin/index.js
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
8 changes: 8 additions & 0 deletions apps/server/src/routes/admin/log.js
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