feat: POST /corrections/ee — DeepSeek rapport complet — 73/73 tests
This commit is contained in:
parent
a6ee76d4a8
commit
77d5a8373e
6 changed files with 385 additions and 23 deletions
61
src/routes/corrections.ts
Normal file
61
src/routes/corrections.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import { Hono } from 'hono'
|
||||
import { authMiddleware } from '../middleware/auth'
|
||||
import type { AppVariables } from '../middleware/auth'
|
||||
import * as correctionController from '../controllers/correctionController'
|
||||
|
||||
const VALID_TACHES_EE = ['EE_T1', 'EE_T2', 'EE_T3']
|
||||
|
||||
const corrections = new Hono<{ Variables: AppVariables }>()
|
||||
|
||||
corrections.post('/ee', authMiddleware, async (c) => {
|
||||
let body: { simulationId?: unknown; contenu?: unknown; tache?: unknown }
|
||||
try {
|
||||
body = await c.req.json()
|
||||
} catch {
|
||||
return c.json(
|
||||
{ error: true, code: 'VALIDATION_ERROR', message: 'Corps de la requête invalide.' },
|
||||
400
|
||||
)
|
||||
}
|
||||
|
||||
if (!body.simulationId || typeof body.simulationId !== 'string') {
|
||||
return c.json(
|
||||
{ error: true, code: 'VALIDATION_ERROR', message: 'simulationId est requis.' },
|
||||
400
|
||||
)
|
||||
}
|
||||
|
||||
if (!body.contenu || typeof body.contenu !== 'string') {
|
||||
return c.json(
|
||||
{ error: true, code: 'VALIDATION_ERROR', message: 'contenu est requis.' },
|
||||
400
|
||||
)
|
||||
}
|
||||
|
||||
if (!body.tache || !VALID_TACHES_EE.includes(body.tache as string)) {
|
||||
return c.json(
|
||||
{
|
||||
error: true,
|
||||
code: 'VALIDATION_ERROR',
|
||||
message: `Tâche invalide. Valeurs acceptées : ${VALID_TACHES_EE.join(', ')}`,
|
||||
},
|
||||
400
|
||||
)
|
||||
}
|
||||
|
||||
const profile = c.get('profile')
|
||||
const result = await correctionController.correctEE(
|
||||
body.simulationId as string,
|
||||
body.contenu as string,
|
||||
body.tache as string,
|
||||
profile
|
||||
)
|
||||
|
||||
if ('error' in result) {
|
||||
return c.json(result, result.status as 401 | 404 | 500)
|
||||
}
|
||||
|
||||
return c.json(result.data, 200)
|
||||
})
|
||||
|
||||
export default corrections
|
||||
Loading…
Add table
Add a link
Reference in a new issue