the beginning of the idiots

This commit is contained in:
2025-10-24 14:51:13 -05:00
parent 0b377030c6
commit cb06217ef7
123 changed files with 10279 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
// models/Tenant.js
// Tenant model definition
class Tenant {
constructor(id, name, subdomain, settings, createdAt, updatedAt) {
this.id = id;
this.name = name;
this.subdomain = subdomain;
this.settings = settings || {};
this.createdAt = createdAt || new Date();
this.updatedAt = updatedAt || new Date();
}
// Static method to create a new tenant
static create(tenantData) {
const id = tenantData.id || require('uuid').v4();
return new Tenant(
id,
tenantData.name,
tenantData.subdomain,
tenantData.settings
);
}
// Method to validate a tenant
validate() {
if (!this.name || !this.subdomain) {
throw new Error('Tenant name and subdomain are required');
}
// Validate subdomain format (alphanumeric and hyphens only)
const subdomainRegex = /^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$/;
if (!subdomainRegex.test(this.subdomain)) {
throw new Error('Invalid subdomain format');
}
return true;
}
}
module.exports = Tenant;

View File

@@ -0,0 +1,50 @@
// models/User.js
// User model definition
class User {
constructor(id, email, passwordHash, firstName, lastName, userType, tenantId, createdAt, updatedAt) {
this.id = id;
this.email = email;
this.passwordHash = passwordHash;
this.firstName = firstName;
this.lastName = lastName;
this.userType = userType; // 'job-seeker' or 'job-provider'
this.tenantId = tenantId;
this.createdAt = createdAt || new Date();
this.updatedAt = updatedAt || new Date();
}
// Static method to create a new user
static create(userData) {
const id = userData.id || require('uuid').v4();
return new User(
id,
userData.email,
userData.passwordHash,
userData.firstName,
userData.lastName,
userData.userType,
userData.tenantId
);
}
// Method to validate a user
validate() {
if (!this.email || !this.passwordHash || !this.firstName || !this.lastName || !this.userType || !this.tenantId) {
throw new Error('Missing required fields');
}
if (!['job-seeker', 'job-provider'].includes(this.userType)) {
throw new Error('User type must be either job-seeker or job-provider');
}
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(this.email)) {
throw new Error('Invalid email format');
}
return true;
}
}
module.exports = User;

View File

@@ -0,0 +1,11 @@
// models/index.js
// This would typically connect to the database and export all models
// For now, we'll define a simple structure
const User = require('./User');
const Tenant = require('./Tenant');
module.exports = {
User,
Tenant
};