Skip to content

Commit

Permalink
Deployment issues #2
Browse files Browse the repository at this point in the history
  • Loading branch information
david emioma committed Mar 31, 2024
1 parent 8dd92ec commit 5b25d7e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions app/api/stores/[storeId]/products/[productId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { UserRole, storeStatus } from "@prisma/client";
import { currentRole, currentUser } from "@/lib/auth";
import { ProductSchema } from "@/lib/validators/product";

const ratelimit = new Ratelimit({
redis,
limiter: Ratelimit.slidingWindow(5, "60 s"),
});
// const ratelimit = new Ratelimit({
// redis,
// limiter: Ratelimit.slidingWindow(5, "60 s"),
// });

export async function PATCH(
request: Request,
Expand All @@ -24,13 +24,13 @@ export async function PATCH(
return new NextResponse("Unauthorized", { status: 401 });
}

const { success } = await ratelimit.limit(user.id ?? "");
// const { success } = await ratelimit.limit(user.id ?? "");

if (!success && process.env.VERCEL_ENV === "production") {
return new NextResponse("Too Many Requests! try again in 1 min", {
status: 429,
});
}
// if (!success && process.env.VERCEL_ENV === "production") {
// return new NextResponse("Too Many Requests! try again in 1 min", {
// status: 429,
// });
// }

const { storeId, productId } = params;

Expand Down
20 changes: 10 additions & 10 deletions app/api/stores/[storeId]/products/new/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { UserRole, storeStatus } from "@prisma/client";
import { currentRole, currentUser } from "@/lib/auth";
import { ProductSchema } from "@/lib/validators/product";

const ratelimit = new Ratelimit({
redis,
limiter: Ratelimit.slidingWindow(5, "60 s"),
});
// const ratelimit = new Ratelimit({
// redis,
// limiter: Ratelimit.slidingWindow(5, "60 s"),
// });

export async function POST(
request: Request,
Expand All @@ -30,13 +30,13 @@ export async function POST(
return new NextResponse("Unauthorized", { status: 401 });
}

const { success } = await ratelimit.limit(user.id ?? "");
// const { success } = await ratelimit.limit(user.id ?? "");

if (!success && process.env.VERCEL_ENV === "production") {
return new NextResponse("Too Many Requests! try again in 1 min", {
status: 429,
});
}
// if (!success && process.env.VERCEL_ENV === "production") {
// return new NextResponse("Too Many Requests! try again in 1 min", {
// status: 429,
// });
// }

//Check if user is a seller
const { role } = await currentRole();
Expand Down

0 comments on commit 5b25d7e

Please sign in to comment.