fix: correct handler bugs exposed by test suite
- ajustements [numEtud]/[idUE]: fix .where() missing and() — PUT/DELETE were applying only numEtud condition, modifying all rows for a student - modules/users/enseignements POST: add try/catch, return 500 on invalid JSON - modules/[idModule] PUT: add try/catch + type check on nom (string required) - modules POST: add .trim() check to reject whitespace-only id/nom - users POST: add .trim() check to reject whitespace-only id/nom/prenom - ues POST: add .trim() check to reject whitespace-only nom - notes POST: add type check (typeof number) and bounds check (0 ≤ note ≤ 20) - ue-modules POST: add coeff >= 0 validation Update robustness tests to reflect fixed behavior (remove [BUG] labels, replace assertRejects with status code assertions).
This commit is contained in:
@@ -33,7 +33,16 @@ export const handler: Handlers<null, AuthenticatedState> = {
|
||||
request: Request,
|
||||
context: FreshContext<AuthenticatedState>,
|
||||
): Promise<Response> {
|
||||
const body: { nom: string } = await request.json();
|
||||
let body: { nom: string };
|
||||
try {
|
||||
body = await request.json();
|
||||
} catch {
|
||||
return new Response(null, { status: 500 });
|
||||
}
|
||||
|
||||
if (typeof body.nom !== "string") {
|
||||
return new Response(null, { status: 400 });
|
||||
}
|
||||
|
||||
const [updated] = await db
|
||||
.update(modules)
|
||||
|
||||
Reference in New Issue
Block a user