-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
95 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { v2 as cloudinary } from 'cloudinary'; | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
// eslint-disable-next-line no-restricted-syntax | ||
export async function POST(request: NextRequest): Promise<NextResponse> { | ||
const body = (await request.json()) as { | ||
paramsToSign: Record<string, string>; | ||
}; | ||
|
||
const { paramsToSign } = body; | ||
|
||
const signature = cloudinary.utils.api_sign_request( | ||
paramsToSign, | ||
process.env.CLOUDINARY_API_SECRET as string, | ||
); | ||
|
||
return NextResponse.json({ signature }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
import { deleteEvent } from '../../../../database/events'; | ||
|
||
type DeleteEventResponseBody = | ||
| { message: string; event?: any } | ||
| { message: string; error?: string }; | ||
|
||
export async function DELETE( | ||
request: NextRequest, | ||
): Promise<NextResponse<DeleteEventResponseBody>> { | ||
const { searchParams } = new URL(request.url); | ||
const eventId = searchParams.get('eventId'); | ||
const { sessionToken } = await request.json(); | ||
|
||
if (!sessionToken || !eventId) { | ||
return NextResponse.json( | ||
{ | ||
message: 'Invalid request', | ||
error: 'Session token or eventId is missing', | ||
}, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
try { | ||
const event = await deleteEvent(sessionToken, parseInt(eventId, 10)); | ||
if (event) { | ||
return NextResponse.json( | ||
{ message: 'Event deleted successfully', event }, | ||
{ status: 200 }, | ||
); | ||
} else { | ||
return NextResponse.json( | ||
{ message: 'Event not found or session expired' }, | ||
{ status: 404 }, | ||
); | ||
} | ||
} catch (error) { | ||
return NextResponse.json( | ||
{ message: 'Internal server error', error: (error as Error).message }, | ||
{ status: 500 }, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.