refactor: revew all design of services, clients, deadcode, ...

This commit is contained in:
Julien Froidefond
2025-08-24 22:03:15 +02:00
parent f4dcc89c11
commit 6fba622003
63 changed files with 969 additions and 1846 deletions

View File

@@ -1,6 +1,5 @@
import { NextRequest, NextResponse } from "next/server";
import { getPool } from "@/services/database";
import { isUserAuthenticated } from "@/lib/server-auth";
// Configuration pour éviter la génération statique
export const dynamic = "force-dynamic";
@@ -8,12 +7,6 @@ export const dynamic = "force-dynamic";
// GET - Récupérer toutes les skills
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
@@ -56,12 +49,6 @@ export async function GET() {
// POST - Créer une nouvelle skill
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, categoryId, description, icon } = await request.json();
if (!name || !categoryId) {
@@ -125,12 +112,6 @@ export async function POST(request: NextRequest) {
// PUT - Mettre à jour une skill
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, categoryId, description, icon } = await request.json();
if (!id || !name || !categoryId) {
@@ -204,12 +185,6 @@ export async function PUT(request: NextRequest) {
// DELETE - Supprimer une skill
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");

View File

@@ -1,6 +1,5 @@
import { NextRequest, NextResponse } from "next/server";
import { getPool } from "@/services/database";
import { isUserAuthenticated } from "@/lib/server-auth";
// GET - Récupérer les membres d'une équipe
export async function GET(
@@ -8,12 +7,6 @@ export async function GET(
{ params }: { params: Promise<{ teamId: string }> }
) {
try {
// Vérifier l'authentification
const isAuthenticated = await isUserAuthenticated();
if (!isAuthenticated) {
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
}
const { teamId } = await params;
if (!teamId) {
@@ -61,12 +54,6 @@ export async function DELETE(
{ params }: { params: Promise<{ teamId: string }> }
) {
try {
// Vérifier l'authentification
const isAuthenticated = await isUserAuthenticated();
if (!isAuthenticated) {
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
}
const { teamId } = await params;
const { memberId } = await request.json();

View File

@@ -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");

View File

@@ -1,6 +1,5 @@
import { NextRequest, NextResponse } from "next/server";
import { getPool } from "@/services/database";
import { isUserAuthenticated } from "@/lib/server-auth";
// DELETE - Supprimer complètement un utilisateur
export async function DELETE(
@@ -8,12 +7,6 @@ export async function DELETE(
{ params }: { params: Promise<{ userId: string }> }
) {
try {
// Vérifier l'authentification
const isAuthenticated = await isUserAuthenticated();
if (!isAuthenticated) {
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
}
const { userId } = await params;
if (!userId) {

View File

@@ -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 la liste des utilisateurs
export async function GET(request: NextRequest) {
try {
// Vérifier l'authentification
const isAuthenticated = await isUserAuthenticated();
if (!isAuthenticated) {
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
}
const pool = getPool();
// Récupérer tous les utilisateurs avec leurs informations d'équipe et d'évaluations

View File

@@ -3,12 +3,11 @@ import { cookies } from "next/headers";
import { evaluationService } from "@/services/evaluation-service";
import { userService } from "@/services/user-service";
import { UserEvaluation, UserProfile } from "@/lib/types";
import { COOKIE_NAME } from "@/lib/auth-utils";
export async function GET(request: NextRequest) {
try {
const cookieStore = await cookies();
const userUuid = cookieStore.get(COOKIE_NAME)?.value;
const userUuid = cookieStore.get("peakSkills_userId")?.value;
// Support pour l'ancien mode avec paramètres (pour la compatibilité)
if (!userUuid) {