* updata validation on public games

This commit is contained in:
Mittani
2024-12-25 19:11:17 +01:00
committed by evanpelle
parent d99219afba
commit af6c519d77
4 changed files with 34 additions and 26 deletions
-11
View File
@@ -11,7 +11,6 @@ import { Client } from './Client';
import { GamePhase, GameServer } from './GameServer';
import { archive } from './Archive';
import { DiscordBot } from './DiscordBot';
import {MAX_USERNAME_LENGTH, MIN_USERNAME_LENGTH} from "../core/Util";
import {validateUsername} from "../core/validations/username";
const __filename = fileURLToPath(import.meta.url);
@@ -121,16 +120,6 @@ app.get('/private_lobby/:id', (req, res) => {
});
});
app.post('/validate-username', (req, res) => {
const { username } = req.body;
if (!username || username.length < MIN_USERNAME_LENGTH || username.length > MAX_USERNAME_LENGTH) {
return res.status(400).json({ success: false, error: `Username must be between ${MIN_USERNAME_LENGTH} and ${MAX_USERNAME_LENGTH} characters.` });
}
res.json({ success: true, message: 'Username is valid.' });
});
wss.on('connection', (ws, req) => {
ws.on('message', (message: string) => {
try {