first commit

This commit is contained in:
Mathieu BOURBON
2026-04-18 16:24:44 +02:00
commit fbb6138c28
72 changed files with 3509 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import type { NextRequest } from 'next/server';
import { hostsService } from '@/modules/hosts';
import { handleError, noContent, notFound, ok } from '@/lib/api/response';
export async function GET(_req: NextRequest, { params }: { params: { id: string } }) {
try {
const host = await hostsService.get(params.id);
if (!host) return notFound('Host not found');
return ok(host);
} catch (err) {
return handleError(err);
}
}
export async function PATCH(req: NextRequest, { params }: { params: { id: string } }) {
try {
const body = await req.json();
const host = await hostsService.update(params.id, body);
return ok(host);
} catch (err) {
return handleError(err);
}
}
export async function DELETE(_req: NextRequest, { params }: { params: { id: string } }) {
try {
await hostsService.delete(params.id);
return noContent();
} catch (err) {
return handleError(err);
}
}