re-order alot, move to bun redis, generalized

This commit is contained in:
creations 2025-05-18 09:53:23 -04:00
parent a646607597
commit 8a9499be85
Signed by: creations
GPG key ID: 8F553AA4320FC711
51 changed files with 559 additions and 916 deletions

View file

@ -0,0 +1,37 @@
const inviteRestrictions: { min: number; max: number; regex: RegExp } = {
min: 4,
max: 15,
regex: /^[a-zA-Z0-9]+$/,
};
export function isValidInvite(invite: string): {
valid: boolean;
error?: string;
} {
if (!invite) {
return { valid: false, error: "" };
}
if (invite.length < inviteRestrictions.min) {
return {
valid: false,
error: `Invite code must be at least ${inviteRestrictions.min} characters long`,
};
}
if (invite.length > inviteRestrictions.max) {
return {
valid: false,
error: `Invite code can't be longer than ${inviteRestrictions.max} characters`,
};
}
if (!inviteRestrictions.regex.test(invite)) {
return {
valid: false,
error: "Invite code contains invalid characters",
};
}
return { valid: true };
}