Initial commit: teaching institution management API.

Express/MongoDB backend with JWT auth, RBAC, S3 uploads, notifications, and scheduled jobs.
This commit is contained in:
2026-08-09 04:18:08 +02:00
commit f04c797be6
107 changed files with 9190 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
// /utils/credentials.js
'use strict';
const crypto = require('crypto');
const LETTERS = 'abcdefghijkmnpqrstuvwxyz';
const DIGITS = '23456789';
const randomFrom = (alphabet, length) => {
let out = '';
const bytes = crypto.randomBytes(length);
for (let i = 0; i < length; i += 1) {
out += alphabet[bytes[i] % alphabet.length];
}
return out;
};
/** Simple password: exactly 2 English letters + 4 digits (e.g. kx4821) */
const generateSimplePassword = () => `${randomFrom(LETTERS, 2)}${randomFrom(DIGITS, 4)}`;
/** Random username: u + 6 digits (e.g. u482910) */
const generateUsername = () => `u${randomFrom(DIGITS, 6)}`;
module.exports = {
generateSimplePassword,
generateUsername,
};