refactor: revew all design of services, clients, deadcode, ...
This commit is contained in:
@@ -1,16 +1,9 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getPool } from "@/services/database";
|
||||
import { isUserAuthenticated } from "@/lib/server-auth";
|
||||
|
||||
// GET - Récupérer toutes les teams
|
||||
export async function GET() {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const pool = getPool();
|
||||
const query = `
|
||||
SELECT
|
||||
@@ -46,12 +39,6 @@ export async function GET() {
|
||||
// POST - Créer une nouvelle team
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { name, direction } = await request.json();
|
||||
|
||||
if (!name || !direction) {
|
||||
@@ -106,12 +93,6 @@ export async function POST(request: NextRequest) {
|
||||
// PUT - Mettre à jour une team
|
||||
export async function PUT(request: NextRequest) {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { id, name, direction } = await request.json();
|
||||
|
||||
if (!id || !name || !direction) {
|
||||
@@ -187,12 +168,6 @@ export async function PUT(request: NextRequest) {
|
||||
// DELETE - Supprimer une team ou une direction
|
||||
export async function DELETE(request: NextRequest) {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const id = searchParams.get("id");
|
||||
const direction = searchParams.get("direction");
|
||||
|
||||
Reference in New Issue
Block a user