Skip to content

Commit c71adee

Browse files
committed
rename all authChecks to auth for consistency
1 parent 5544bf8 commit c71adee

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

app/api/v2/escape/menu/categories/route.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ export async function PATCH(
1515
const category: MenuCategory = await req.json();
1616

1717
const session = await getServerSession(authOptions);
18-
const authCheck: Auth = new Auth(session, category)
18+
const auth: Auth = new Auth(session, category)
1919
.requireRoles([])
2020
.requireParams(["id"]); // only id is strictly required
2121

22-
if (authCheck.failed) return authCheck.response;
22+
if (auth.failed) return auth.response;
2323

2424

2525
const newProduct = await prismaClient.menuCategory.update({
@@ -30,7 +30,7 @@ export async function PATCH(
3030
})
3131

3232

33-
return authCheck.verify(NextResponse.json(JSON.stringify(newProduct)));
33+
return auth.verify(NextResponse.json(JSON.stringify(newProduct)));
3434
}
3535

3636

@@ -41,16 +41,16 @@ export async function POST(
4141
const category: MenuCategoryCreate = await req.json();
4242

4343
const session = await getServerSession(authOptions);
44-
const authCheck = new Auth(session, category)
44+
const auth = new Auth(session, category)
4545
.requireRoles([])
4646
.requireParams(["name"]);
4747

48-
if (authCheck.failed) return authCheck.response;
48+
if (auth.failed) return auth.response;
4949

5050

5151
const newCategory = await prismaClient.menuCategory.create({
5252
data: category
5353
});
5454

55-
return authCheck.verify(NextResponse.json(JSON.stringify(newCategory)));
55+
return auth.verify(NextResponse.json(JSON.stringify(newCategory)));
5656
}

app/api/v2/escape/menu/products/[productId]/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ export async function DELETE(
1414
let params = await context.params;
1515

1616
const session = await getServerSession(authOptions);
17-
const authCheck = new Auth(session, params)
17+
const auth = new Auth(session, params)
1818
.requireRoles([])
1919
.requireParams(["productId"]);
2020

2121
const productId = Number(params.productId);
2222

23-
if (authCheck.failed) return authCheck.response;
23+
if (auth.failed) return auth.response;
2424

2525
// verify productId is an integer
2626
if (isNaN(productId) || !productId) {
@@ -41,5 +41,5 @@ export async function DELETE(
4141
}
4242
}
4343

44-
return authCheck.verify(NextResponse.json(JSON.stringify({})));
44+
return auth.verify(NextResponse.json(JSON.stringify({})));
4545
}

app/api/v2/escape/menu/products/route.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export async function PATCH(
1414
const product: MenuProduct = await req.json();
1515

1616
const session = await getServerSession(authOptions);
17-
const authCheck = new Auth(session, product)
17+
const auth = new Auth(session, product)
1818
.requireRoles([])
1919
.requireParams(["id"]);
2020

21-
if (authCheck.failed) return authCheck.response;
21+
if (auth.failed) return auth.response;
2222

2323

2424
const newProduct = await prismaClient.menuProduct.update({
@@ -28,7 +28,7 @@ export async function PATCH(
2828
data: product
2929
});
3030

31-
return authCheck.verify(NextResponse.json(JSON.stringify(newProduct)));
31+
return auth.verify(NextResponse.json(JSON.stringify(newProduct)));
3232
}
3333

3434

@@ -39,19 +39,19 @@ export async function POST(
3939
const product: MenuProductCreate = await req.json();
4040

4141
const session = await getServerSession(authOptions);
42-
const authCheck = new Auth(session, product)
42+
const auth = new Auth(session, product)
4343
.requireRoles([])
4444
.requireParams(["name", "hidden", "price", "volume", "glutenfree", "category_id", "priceVolunteer"]);
4545

46-
if (authCheck.failed) return authCheck.response;
46+
if (auth.failed) return auth.response;
4747

4848

4949

5050
await prisma.menuProduct.create({
5151
data: product
5252
});
5353

54-
return authCheck.verify(NextResponse.json(JSON.stringify({})));
54+
return auth.verify(NextResponse.json(JSON.stringify({})));
5555
}
5656

5757
const menuCategoryWithProducts = Prisma.validator<Prisma.MenuCategoryDefaultArgs>()({include: {menu_products: true}})

0 commit comments

Comments
 (0)