Compare commits

..

3 Commits

Author SHA1 Message Date
djalim da88de418b chore(drizzle.config.ts): import process for env variable support 2026-04-22 14:39:41 +02:00
djalim 41bc419a95 chore(deps): update drizzle-orm to 0.45.2 and pg to 8.20.0 2026-04-22 14:39:41 +02:00
djalim 0a3069762d feat(promotions): add CRUD endpoints for promotion by id
- GET /promotions/{idPromo} returns promotion or 404
- PUT /promotions/{idPromo} updates year or 404
- DELETE /promotions/{idPromo} deletes promotion or 404
- Only employees allowed, otherwise 403
2026-04-22 14:39:41 +02:00
-23
View File
@@ -3,7 +3,6 @@ import { db } from "../../../../databases/db.ts";
import { ues } from "../../../../databases/schema.ts";
export const handler: Handlers = {
// #32 GET /ues
async GET() {
try {
const result = await db.select().from(ues);
@@ -17,26 +16,4 @@ export const handler: Handlers = {
return new Response("Failed to fetch data", { status: 500 });
}
},
// #33 POST /ues
async POST(request) {
try {
const body = await request.json();
const { nom } = body;
if (!nom) {
return new Response("Champ 'nom' manquant", { status: 400 });
}
const result = await db.insert(ues).values({ nom }).returning();
return new Response(JSON.stringify(result[0]), {
status: 201,
headers: { "Content-Type": "application/json" },
});
} catch (error) {
console.error("Error creating UE:", error);
return new Response("Failed to create UE", { status: 500 });
}
},
};