chore(api): add explicit type casting for request payloads
This commit is contained in:
@@ -3,10 +3,10 @@ import { prisma } from "../../../../../lib/prisma";
|
||||
|
||||
type Params = { params: Promise<{ id: string }> };
|
||||
|
||||
// PATCH /api/admin/daily/[id] — modifier un puzzle
|
||||
// PATCH /api/admin/daily/[id] - modifier un puzzle
|
||||
export async function PATCH(req: Request, { params }: Params) {
|
||||
const { id } = await params;
|
||||
const { startArticle, targetArticle } = await req.json() as {
|
||||
const { startArticle, targetArticle } = (await req.json()) as {
|
||||
startArticle: string;
|
||||
targetArticle: string;
|
||||
};
|
||||
@@ -17,7 +17,7 @@ export async function PATCH(req: Request, { params }: Params) {
|
||||
return NextResponse.json(puzzle);
|
||||
}
|
||||
|
||||
// DELETE /api/admin/daily/[id] — supprimer un puzzle
|
||||
// DELETE /api/admin/daily/[id] - supprimer un puzzle
|
||||
export async function DELETE(_req: Request, { params }: Params) {
|
||||
const { id } = await params;
|
||||
await prisma.dailyPuzzle.delete({ where: { id } });
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "../../../../lib/prisma";
|
||||
|
||||
// GET /api/admin/daily — liste tous les puzzles
|
||||
// GET /api/admin/daily - liste tous les puzzles
|
||||
export async function GET() {
|
||||
const puzzles = await prisma.dailyPuzzle.findMany({
|
||||
orderBy: { date: "desc" },
|
||||
@@ -11,9 +11,9 @@ export async function GET() {
|
||||
return NextResponse.json(puzzles);
|
||||
}
|
||||
|
||||
// POST /api/admin/daily — créer un puzzle pour une date
|
||||
// POST /api/admin/daily - créer un puzzle pour une date
|
||||
export async function POST(req: Request) {
|
||||
const { date, startArticle, targetArticle } = await req.json() as {
|
||||
const { date, startArticle, targetArticle } = (await req.json()) as {
|
||||
date: string;
|
||||
startArticle: string;
|
||||
targetArticle: string;
|
||||
|
||||
Reference in New Issue
Block a user