refactor: revew all design of services, clients, deadcode, ...
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user