ai generated solutions to our ai generated problems

This commit is contained in:
Heidi
2026-06-19 23:54:11 +01:00
parent bccd2bf405
commit 07b087e7df
4 changed files with 222 additions and 67 deletions
+24
View File
@@ -20,6 +20,12 @@ function isAllowedApiUrl(req) {
return keys.every((key) => key === 'limit') && Number.isInteger(limit) && limit >= 1 && limit <= 100
}
if (url.pathname === '/api/tss/leaderboard/players') {
const keys = [...params.keys()]
const limit = Number(params.get('limit') || 100)
return keys.every((key) => key === 'limit') && Number.isInteger(limit) && limit >= 1 && limit <= 100
}
if (url.pathname === '/api/tss/games/recent') {
const keys = [...params.keys()]
const limit = Number(params.get('limit') || 50)
@@ -56,6 +62,24 @@ function isAllowedApiUrl(req) {
)
}
if (url.pathname === '/api/tss/players/search') {
const keys = [...params.keys()]
const query = params.get('q') || params.get('name') || ''
const limit = Number(params.get('limit') || 25)
return (
keys.every((key) => ['q', 'name', 'limit'].includes(key)) &&
query.length >= 2 &&
query.length <= MAX_TEAM_NAME_LENGTH &&
Number.isInteger(limit) &&
limit >= 1 &&
limit <= 25
)
}
if (/^\/api\/tss\/player\/[0-9]{1,32}$/.test(url.pathname)) {
return [...params.keys()].length === 0
}
if ([...params.keys()].length) return false
try {