-
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.
Merge pull request #61 from emil-webkom/debugAndAeresemiler
Debug and aeresemiler
- Loading branch information
Showing
20 changed files
with
571 additions
and
310 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,41 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { db } from "@/lib/db"; | ||
|
||
export async function GET(request: NextRequest) { | ||
try { | ||
const aeresemilere = await db.aeresEmiler.findMany(); | ||
return NextResponse.json(aeresemilere, { status: 200 }); | ||
} catch (error) { | ||
console.error("Error fetching aeresEmilere:", error); | ||
return NextResponse.json( | ||
{ error: "Failed to fetch aeresEmilere" }, | ||
{ status: 500 } | ||
); | ||
} | ||
} | ||
|
||
// Takes a json body-object on the format {id: String} | ||
export async function DELETE(request: NextRequest) { | ||
const body = await request.json(); | ||
const deleteId = body.id; | ||
|
||
if (!deleteId) { | ||
return NextResponse.json({ error: "ID is required" }, { status: 400 }); | ||
} | ||
|
||
try { | ||
const aeresemilere = await db.aeresEmiler.delete({ | ||
where: { id: deleteId } | ||
}); | ||
return NextResponse.json( | ||
{ | ||
message: "Deleted aeresEmilere", | ||
aeresemilere: [aeresemilere] | ||
}, | ||
{ status: 200 }, | ||
); | ||
} catch (error) { | ||
console.log("Error deleting aeresEmilere", error); | ||
return NextResponse.json({ error: error }, { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import fetchKomite from "@/utils/komite/fetchers"; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
|
||
|
||
export async function GET(request: NextRequest){ | ||
try { | ||
const data = await fetchKomite(); | ||
|
||
if (!data) { | ||
return NextResponse.json({ message: "No data found" }, { status: 404 }); | ||
} | ||
return NextResponse.json(data, { status: 200 }); | ||
} catch (error) { | ||
console.error("Error fetching komite-data:", error); | ||
return NextResponse.json( | ||
{ message: "Internal server error" }, | ||
{ 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
Oops, something went wrong.