First part of backend rework

- Added the base data structure for the new database
- Added the new routes for the new database
- Reworked the users endpoints
This commit is contained in:
2024-02-26 10:20:29 +01:00
parent 902bab14c7
commit 0ddbc437b9
40 changed files with 1237 additions and 1911 deletions

View File

@@ -1,9 +1,22 @@
import crypto from 'crypto';
export function random(x, y) {
return crypto.randomInt(x, y);
return crypto.randomInt(x, y + 1);
}
export function random2(min, max) {
const range = max - min + 1;
const byteLength = Math.ceil(Math.log2(range) / 8);
let randomValue;
do {
const randomBytes = crypto.randomBytes(byteLength);
randomValue = parseInt(randomBytes.toString('hex'), 16);
} while (randomValue >= range);
return randomValue + min;
}
export function randomHEX(x) {
return crypto.randomBytes(x).toString('hex');
}
}