Skip to content

Commit 3d96e2b

Browse files
committed
Fixed return and interfaces
1 parent 7da5c28 commit 3d96e2b

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/app/api/unclaimedItems/route.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ test("Should give correct database queries", async () => {
4444

4545
// Check that the response json was written correctly
4646
const expectedRet = {
47-
numberOfItems: 3,
4847
unclaimedItems: await dbMock.unclaimedItem.findMany(),
4948
};
5049
const json = await res.json();

src/app/api/unclaimedItems/route.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ import { NextResponse } from "next/server";
66

77
// Response for GET /api/unclaimedItems
88
interface UnclaimedItemsResponse {
9-
numberOfItems: number | 0;
10-
unclaimedItems:
11-
| {
12-
id: number;
13-
name: string;
14-
quantity: number;
15-
expirationDate: Date | null;
16-
}[]
17-
| [];
9+
unclaimedItems: {
10+
id: number;
11+
name: string;
12+
quantity: number;
13+
expirationDate: Date | null;
14+
}[];
1815
}
1916

2017
/**
@@ -35,7 +32,6 @@ export async function GET() {
3532
const unclaimedItems = await db.unclaimedItem.findMany();
3633

3734
return NextResponse.json({
38-
numberOfItems: unclaimedItems?.length, // ?.length for when unclaimedItems is undefined
3935
unclaimedItems: unclaimedItems,
4036
} as UnclaimedItemsResponse);
4137
}

0 commit comments

Comments
 (0)