build fix

This commit is contained in:
alma 2025-05-05 12:55:09 +02:00
parent 70a921b0f5
commit 5873bb771f
18 changed files with 58 additions and 95 deletions

View File

@ -26,8 +26,9 @@ import { prisma } from "@/lib/prisma";
*/
export async function GET(
req: NextRequest,
{ params }: { params: { id: string; eventId: string } }
props: { params: Promise<{ id: string; eventId: string }> }
) {
const params = await props.params;
const session = await getServerSession(authOptions);
if (!session?.user?.username) {
@ -105,8 +106,9 @@ export async function GET(
*/
export async function PUT(
req: NextRequest,
{ params }: { params: { id: string; eventId: string } }
props: { params: Promise<{ id: string; eventId: string }> }
) {
const params = await props.params;
const session = await getServerSession(authOptions);
if (!session?.user?.username) {
@ -208,8 +210,9 @@ export async function PUT(
*/
export async function DELETE(
req: NextRequest,
{ params }: { params: { id: string; eventId: string } }
props: { params: Promise<{ id: string; eventId: string }> }
) {
const params = await props.params;
const session = await getServerSession(authOptions);
if (!session?.user?.username) {

View File

@ -24,10 +24,8 @@ import { prisma } from "@/lib/prisma";
* - 404: Calendar not found.
* - 500: Server error occurred while retrieving events.
*/
export async function GET(
req: NextRequest,
{ params }: { params: { id: string } }
) {
export async function GET(req: NextRequest, props: { params: Promise<{ id: string }> }) {
const params = await props.params;
const session = await getServerSession(authOptions);
if (!session?.user?.username) {
@ -105,10 +103,8 @@ export async function GET(
* @throws {400} If the required fields (title, start, end) are missing.
* @throws {500} If there is a server error during event creation.
*/
export async function POST(
req: NextRequest,
{ params }: { params: { id: string } }
) {
export async function POST(req: NextRequest, props: { params: Promise<{ id: string }> }) {
const params = await props.params;
const session = await getServerSession(authOptions);
if (!session?.user?.username) {

View File

@ -5,10 +5,8 @@ import { prisma } from "@/lib/prisma";
import crypto from "crypto";
// Non testé, généré automatiquement par IA
export async function POST(
req: NextRequest,
{ params }: { params: { id: string } }
) {
export async function POST(req: NextRequest, props: { params: Promise<{ id: string }> }) {
const params = await props.params;
const session = await getServerSession(authOptions);
if (!session?.user?.username) {

View File

@ -6,7 +6,7 @@ import { invalidateEmailContentCache, invalidateFolderCache } from '@/lib/redis'
export async function POST(
request: Request,
context: { params: { id: string } }
context: { params: Promise<{ id: string }> }
) {
try {
const session = await getServerSession(authOptions);

View File

@ -31,7 +31,7 @@ const invalidateCache = (userId: string, folder?: string) => {
// Mark email as read
export async function POST(
request: Request,
context: { params: { id: string } }
context: { params: Promise<{ id: string }> }
) {
try {
const session = await getServerSession(authOptions);

View File

@ -14,7 +14,7 @@ import { getCachedEmailContent, invalidateEmailContentCache } from '@/lib/redis'
export async function GET(
request: Request,
context: { params: { id: string } }
context: { params: Promise<{ id: string }> }
) {
try {
const session = await getServerSession(authOptions);
@ -73,7 +73,7 @@ export async function GET(
// Add a route to mark email as read
export async function POST(
request: Request,
context: { params: { id: string } }
context: { params: Promise<{ id: string }> }
) {
try {
const session = await getServerSession(authOptions);

View File

@ -3,10 +3,8 @@ import { getServerSession } from "next-auth/next";
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
import { prisma } from "@/lib/prisma";
export async function DELETE(
req: NextRequest,
{ params }: { params: { id: string } }
) {
export async function DELETE(req: NextRequest, props: { params: Promise<{ id: string }> }) {
const params = await props.params;
const session = await getServerSession(authOptions);
if (!session?.user?.id) {

View File

@ -2,10 +2,8 @@ import { getServerSession } from "next-auth/next";
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
import { NextResponse } from "next/server";
export async function GET(
req: Request,
{ params }: { params: { groupId: string } }
) {
export async function GET(req: Request, props: { params: Promise<{ groupId: string }> }) {
const params = await props.params;
const session = await getServerSession(authOptions);
if (!session) {
@ -60,10 +58,8 @@ export async function GET(
}
}
export async function POST(
req: Request,
{ params }: { params: { groupId: string } }
) {
export async function POST(req: Request, props: { params: Promise<{ groupId: string }> }) {
const params = await props.params;
const session = await getServerSession(authOptions);
if (!session) {

View File

@ -26,10 +26,8 @@ async function getAdminToken() {
return data.access_token;
}
export async function GET(
req: Request,
{ params }: { params: { groupId: string } }
) {
export async function GET(req: Request, props: { params: Promise<{ groupId: string }> }) {
const params = await props.params;
try {
const session = await getServerSession(authOptions);
if (!session) {
@ -62,10 +60,8 @@ export async function GET(
}
}
export async function PUT(
req: Request,
{ params }: { params: { groupId: string } }
) {
export async function PUT(req: Request, props: { params: Promise<{ groupId: string }> }) {
const params = await props.params;
try {
const session = await getServerSession(authOptions);
if (!session) {
@ -101,10 +97,8 @@ export async function PUT(
}
}
export async function PATCH(
req: Request,
{ params }: { params: { groupId: string } }
) {
export async function PATCH(req: Request, props: { params: Promise<{ groupId: string }> }) {
const params = await props.params;
try {
const session = await getServerSession(authOptions);
if (!session) {
@ -140,10 +134,8 @@ export async function PATCH(
}
}
export async function DELETE(
req: Request,
{ params }: { params: { groupId: string } }
) {
export async function DELETE(req: Request, props: { params: Promise<{ groupId: string }> }) {
const params = await props.params;
try {
const session = await getServerSession(authOptions);
if (!session) {

View File

@ -21,8 +21,9 @@ async function checkAuth(request: Request) {
// DELETE endpoint to remove an attachment
export async function DELETE(
request: Request,
{ params }: { params: { missionId: string, attachmentId: string } }
props: { params: Promise<{ missionId: string, attachmentId: string }> }
) {
const params = await props.params;
try {
const { authorized, userId } = await checkAuth(request);
if (!authorized || !userId) {

View File

@ -23,8 +23,9 @@ async function checkAuth(request: Request) {
// GET endpoint to download an attachment
export async function GET(
request: Request,
{ params }: { params: { missionId: string, attachmentId: string } }
props: { params: Promise<{ missionId: string, attachmentId: string }> }
) {
const params = await props.params;
try {
const { authorized, userId } = await checkAuth(request);
if (!authorized || !userId) {

View File

@ -18,10 +18,8 @@ async function checkAuth(request: Request) {
}
// GET endpoint to list all attachments for a mission
export async function GET(
request: Request,
{ params }: { params: { missionId: string } }
) {
export async function GET(request: Request, props: { params: Promise<{ missionId: string }> }) {
const params = await props.params;
try {
const { authorized, userId } = await checkAuth(request);
if (!authorized || !userId) {

View File

@ -19,10 +19,8 @@ async function checkAuth(request: Request) {
}
// GET endpoint to retrieve a mission by ID
export async function GET(
request: Request,
{ params }: { params: { missionId: string } }
) {
export async function GET(request: Request, props: { params: Promise<{ missionId: string }> }) {
const params = await props.params;
try {
const { authorized, userId } = await checkAuth(request);
if (!authorized || !userId) {
@ -91,10 +89,8 @@ export async function GET(
}
// PUT endpoint to update a mission
export async function PUT(
request: Request,
{ params }: { params: { missionId: string } }
) {
export async function PUT(request: Request, props: { params: Promise<{ missionId: string }> }) {
const params = await props.params;
try {
const { authorized, userId } = await checkAuth(request);
if (!authorized || !userId) {
@ -246,10 +242,8 @@ export async function PUT(
}
// DELETE endpoint to remove a mission
export async function DELETE(
request: Request,
{ params }: { params: { missionId: string } }
) {
export async function DELETE(request: Request, props: { params: Promise<{ missionId: string }> }) {
const params = await props.params;
try {
const { authorized, userId } = await checkAuth(request);
if (!authorized || !userId) {

View File

@ -6,7 +6,7 @@ import { NotificationService } from '@/lib/services/notifications/notification-s
// POST /api/notifications/{id}/read
export async function POST(
request: Request,
context: { params: { id: string } }
context: { params: Promise<{ id: string }> }
) {
try {
// Authenticate user

View File

@ -2,10 +2,8 @@ import { getServerSession } from "next-auth/next";
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
import { NextResponse } from "next/server";
export async function PUT(
req: Request,
{ params }: { params: { userId: string } }
) {
export async function PUT(req: Request, props: { params: Promise<{ userId: string }> }) {
const params = await props.params;
const session = await getServerSession(authOptions);
if (!session) {

View File

@ -6,10 +6,8 @@ import { getKeycloakAdminClient } from "@/lib/keycloak";
// Fix for Next.js "params should be awaited" error
export const dynamic = 'force-dynamic';
export async function GET(
request: Request,
{ params }: { params: { userId?: string } }
) {
export async function GET(request: Request, props: { params: Promise<{ userId?: string }> }) {
const params = await props.params;
try {
const session = await getServerSession(authOptions);
if (!session) {
@ -85,10 +83,8 @@ export async function GET(
}
}
export async function PUT(
request: Request,
{ params }: { params: { userId?: string } }
) {
export async function PUT(request: Request, props: { params: Promise<{ userId?: string }> }) {
const params = await props.params;
try {
const session = await getServerSession(authOptions);
if (!session) {

View File

@ -65,7 +65,7 @@ async function deleteLeantimeUser(email: string, requestingUserId: string): Prom
// Check if the requesting user has permission to delete this user
// This is a placeholder - implement proper permission check based on your requirements
if (!await hasDeletePermission(requestingUserId, leantimeUserId)) {
if (!(await hasDeletePermission(requestingUserId, leantimeUserId))) {
return {
success: false,
error: 'Unauthorized to delete this user'
@ -120,10 +120,8 @@ async function hasDeletePermission(requestingUserId: string, targetUserId: numbe
return true;
}
export async function DELETE(
req: Request,
{ params }: { params: { userId: string } }
) {
export async function DELETE(req: Request, props: { params: Promise<{ userId: string }> }) {
const params = await props.params;
const session = await getServerSession(authOptions);
const userId = params.userId; // Store userId from params to avoid sync access issues
@ -210,10 +208,8 @@ export async function DELETE(
}
}
export async function PUT(
req: Request,
{ params }: { params: { userId: string } }
) {
export async function PUT(req: Request, props: { params: Promise<{ userId: string }> }) {
const params = await props.params;
const session = await getServerSession(authOptions);
if (!session) {

View File

@ -9,10 +9,8 @@ import { simpleParser } from 'mailparser';
const emailContentCache = new Map<string, { content: string, timestamp: number }>();
const CACHE_TTL = 30 * 60 * 1000; // 30 minutes in milliseconds
export async function GET(
request: Request,
{ params }: { params: { id: string } }
) {
export async function GET(request: Request, props: { params: Promise<{ id: string }> }) {
const params = await props.params;
try {
console.log(`[DEBUG] GET request for single email ID: ${params.id}`);
@ -162,10 +160,8 @@ export async function GET(
}
// Handle marking emails as read
export async function POST(
request: Request,
{ params }: { params: { id: string } }
) {
export async function POST(request: Request, props: { params: Promise<{ id: string }> }) {
const params = await props.params;
try {
console.log(`[DEBUG] POST request for email ID: ${params.id}`);