Initial commit: OmniAI backend server
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
const ENTERPRISE_BETA_INITIAL_CREDITS = 1500;
|
||||
const ENTERPRISE_BETA_INITIAL_BALANCE_CENTS = ENTERPRISE_BETA_INITIAL_CREDITS * 100;
|
||||
|
||||
const ENTERPRISE_BETA_ACCOUNTS = [
|
||||
{
|
||||
enterpriseId: "ent-beta-001",
|
||||
enterpriseName: "Beta Enterprise 001",
|
||||
adminUsername: "enterprise_admin_001",
|
||||
inviteCode: "ENT-BETA-001",
|
||||
initialCredits: ENTERPRISE_BETA_INITIAL_CREDITS,
|
||||
},
|
||||
{
|
||||
enterpriseId: "ent-beta-002",
|
||||
enterpriseName: "Beta Enterprise 002",
|
||||
adminUsername: "enterprise_admin_002",
|
||||
inviteCode: "ENT-BETA-002",
|
||||
initialCredits: ENTERPRISE_BETA_INITIAL_CREDITS,
|
||||
},
|
||||
{
|
||||
enterpriseId: "ent-beta-003",
|
||||
enterpriseName: "Beta Enterprise 003",
|
||||
adminUsername: "enterprise_admin_003",
|
||||
inviteCode: "ENT-BETA-003",
|
||||
initialCredits: ENTERPRISE_BETA_INITIAL_CREDITS,
|
||||
},
|
||||
{
|
||||
enterpriseId: "ent-beta-004",
|
||||
enterpriseName: "Beta Enterprise 004",
|
||||
adminUsername: "enterprise_admin_004",
|
||||
inviteCode: "ENT-BETA-004",
|
||||
initialCredits: ENTERPRISE_BETA_INITIAL_CREDITS,
|
||||
},
|
||||
];
|
||||
|
||||
function normalizeEnterpriseInviteCode(value) {
|
||||
return String(value || "")
|
||||
.trim()
|
||||
.replace(/[\s-]/g, "")
|
||||
.toUpperCase();
|
||||
}
|
||||
|
||||
const ENTERPRISE_BETA_ACCOUNT_BY_CODE = new Map(
|
||||
ENTERPRISE_BETA_ACCOUNTS.map((account) => [
|
||||
normalizeEnterpriseInviteCode(account.inviteCode),
|
||||
account,
|
||||
]),
|
||||
);
|
||||
|
||||
function findEnterpriseBetaAccountByInviteCode(value) {
|
||||
return ENTERPRISE_BETA_ACCOUNT_BY_CODE.get(normalizeEnterpriseInviteCode(value)) || null;
|
||||
}
|
||||
|
||||
function isEnterpriseBetaInviteCode(value) {
|
||||
return Boolean(findEnterpriseBetaAccountByInviteCode(value));
|
||||
}
|
||||
|
||||
function createEnterpriseBetaPasswordMap(env = process.env) {
|
||||
const sharedPassword = String(env.ENTERPRISE_BETA_ADMIN_PASSWORD || "").trim();
|
||||
const entries = ENTERPRISE_BETA_ACCOUNTS.map((account, index) => {
|
||||
const suffix = String(index + 1).padStart(3, "0");
|
||||
const specificPassword = String(env[`ENTERPRISE_BETA_ADMIN_${suffix}_PASSWORD`] || "").trim();
|
||||
return [account.adminUsername, specificPassword || sharedPassword];
|
||||
});
|
||||
return new Map(entries);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ENTERPRISE_BETA_ACCOUNTS,
|
||||
ENTERPRISE_BETA_INITIAL_BALANCE_CENTS,
|
||||
ENTERPRISE_BETA_INITIAL_CREDITS,
|
||||
createEnterpriseBetaPasswordMap,
|
||||
findEnterpriseBetaAccountByInviteCode,
|
||||
isEnterpriseBetaInviteCode,
|
||||
normalizeEnterpriseInviteCode,
|
||||
};
|
||||
Reference in New Issue
Block a user