Skip to content

Commit b6a3bff

Browse files
committed
Fixed build errors
1 parent 422449c commit b6a3bff

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { testApiHandler } from "next-test-api-route-handler";
22
import * as appHandler from "./route";
33
import { expect, test } from "@jest/globals";
4-
import { authMock } from "@/test/authMock";
4+
// import { authMock } from "@/test/authMock";
55
import { validateSession, invalidateSession } from "@/test/util/authMockUtils";
66
import { manyUnclaimedItems } from "@/test/util/dbMockUtils";
77
import { dbMock } from "@/test/dbMock";

src/app/api/unclaimedItems/route.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NextRequest } from 'next/server';
1+
// import { NextRequest } from 'next/server';
22
import { auth } from '@/auth';
33
import { internalError, authenticationError, successResponse } from '@/util/responses';
44
import { db } from '@/db';
@@ -38,8 +38,12 @@ export async function GET() {
3838
const unclaimedItems = await db.unclaimedItem.findMany();
3939

4040
return successResponse({ unclaimedItems });
41-
} catch (err: any) {
42-
console.error(err?.message);
41+
} catch (err: unknown) {
42+
if (err instanceof Error) {
43+
console.error(err.message);
44+
} else {
45+
console.error('An unknown error occurred');
46+
}
4347
return internalError();
4448
}
4549
}

src/test/util/authMockUtils.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { authMock } from "@/test/authMock";
2+
import { UserType } from "@prisma/client";
23

34
// Helper util methods for testing
45

@@ -14,7 +15,9 @@ export async function invalidateSession() {
1415
* @param user Optional, default is { id: "1234", type: "ADMIN" }
1516
* @param expires Optional, default is ""
1617
*/
17-
export async function validateSession(user: any = { id: "1234", type: "ADMIN" }, expires: string = "") {
18+
export async function validateSession(
19+
user: { id: string, type: UserType } = { id: "1234", type: "ADMIN" },
20+
expires: string = "") {
1821
authMock.mockReturnValueOnce({
1922
user: {
2023
id: user.id,

src/util/responses.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ export function ok() {
2828
return NextResponse.json({ message: "OK" }, { status: 200 });
2929
}
3030

31-
export function successResponse(data: any) {
31+
export function successResponse<T>(data: T) {
3232
return NextResponse.json(data, { status: 200 });
3333
}

0 commit comments

Comments
 (0)