Spaces:
Paused
Paused
File size: 1,993 Bytes
04f3552 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | const prisma = require('./src/lib/prisma');
const bcrypt = require('bcryptjs');
const NICHES = ['Tech', 'Health', 'Finance', 'Travel', 'Lifestyle', 'Business', 'Education'];
const generateRandomUsersAndWorkspaces = async () => {
const salt = await bcrypt.genSalt(10);
const hashedPassword = await bcrypt.hash('Password123!', salt);
let count = 0;
console.log('Inserting 20 fully onboarded users...');
for (let i = 0; i < 20; i++) {
const randomSuffix = Math.floor(Math.random() * 1000000);
const firstName = `User${randomSuffix}`;
const lastName = `Test`;
const name = `${firstName} ${lastName}`;
const email = `user${randomSuffix}@example.com`;
const domain = `site${randomSuffix}.com`;
const websiteName = `Awesome Site ${randomSuffix}`;
const description = `This is a randomly generated description for ${domain}. We provide great content about our niche.`;
const niche = NICHES[Math.floor(Math.random() * NICHES.length)];
try {
await prisma.user.create({
data: {
name,
email,
hashedPassword,
role: 'CLIENT',
teamMemberships: {
create: {
role: 'OWNER',
workspace: {
create: {
domain,
websiteName,
description,
niche,
country: 'USA',
language: 'English',
monthlyTraffic: Math.floor(Math.random() * 50000) + 1000,
}
}
}
}
}
});
count++;
} catch (err) {
console.error(`Error creating user ${email}:`, err.message);
}
}
console.log(`Successfully inserted ${count} fully onboarded users with workspaces!`);
console.log('Sample user email:', `user*@example.com`);
console.log('All users have the password: Password123!');
await prisma.$disconnect();
};
generateRandomUsersAndWorkspaces();
|