fix input limits, use redis SCAN, move interval to hooks
This commit is contained in:
parent
6e93a2905b
commit
a352314d42
4 changed files with 40 additions and 16 deletions
|
|
@ -19,6 +19,11 @@ export const POST: RequestHandler = async ({ request }) => {
|
|||
|
||||
try {
|
||||
const { sessionToken, tileIndex } = await request.json();
|
||||
|
||||
if (!Number.isInteger(tileIndex) || tileIndex < 0 || tileIndex > 24) {
|
||||
return json({ error: 'Invalid tileIndex' }, { status: 400 });
|
||||
}
|
||||
|
||||
const sessionRaw = await redis.get(getSessionKey(sessionToken));
|
||||
const game = sessionRaw ? JSON.parse(sessionRaw) : null;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export const POST: RequestHandler = async ({ request }) => {
|
|||
const { betAmount, mineCount } = await request.json();
|
||||
const userId = Number(session.user.id);
|
||||
|
||||
if (!betAmount || !mineCount || mineCount < 3 || mineCount > 24) {
|
||||
if (!betAmount || betAmount <= 0 || !mineCount || mineCount < 3 || mineCount > 24) {
|
||||
return json({ error: 'Invalid bet amount or mine count' }, { status: 400 });
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue