Update seed

Create new users updated to create a longer random value to prevent duplication when seeding db. Beer images now use a generated caption and alt text.
This commit is contained in:
Aaron William Po
2023-04-11 20:22:21 -04:00
parent 4594e22a4f
commit 6c8a510d80
3 changed files with 46 additions and 22 deletions

View File

@@ -20,12 +20,15 @@ const createNewBeerImages = async ({
for (let i = 0; i < numberOfImages; i++) { for (let i = 0; i < numberOfImages; i++) {
const beerPost = beerPosts[Math.floor(Math.random() * beerPosts.length)]; const beerPost = beerPosts[Math.floor(Math.random() * beerPosts.length)];
const user = users[Math.floor(Math.random() * users.length)]; const user = users[Math.floor(Math.random() * users.length)];
const caption = faker.lorem.sentence();
const alt = faker.lorem.sentence();
beerImagesPromises.push( beerImagesPromises.push(
prisma.beerImage.create({ prisma.beerImage.create({
data: { data: {
path: 'https://picsum.photos/5000/5000', path: 'https://picsum.photos/5000/5000',
alt: 'Placeholder beer image.', alt,
caption: 'Placeholder beer image caption.', caption,
beerPost: { connect: { id: beerPost.id } }, beerPost: { connect: { id: beerPost.id } },
postedBy: { connect: { id: user.id } }, postedBy: { connect: { id: user.id } },
createdAt, createdAt,

View File

@@ -18,7 +18,7 @@ const createNewUsers = async ({ numberOfUsers }: CreateNewUsersArgs) => {
// eslint-disable-next-line no-plusplus // eslint-disable-next-line no-plusplus
for (let i = 0; i < numberOfUsers; i++) { for (let i = 0; i < numberOfUsers; i++) {
const randomValue = crypto.randomBytes(8).toString('hex'); const randomValue = crypto.randomBytes(10).toString('hex');
const firstName = faker.name.firstName(); const firstName = faker.name.firstName();
const lastName = faker.name.lastName(); const lastName = faker.name.lastName();
const username = `${firstName[0]}.${lastName}.${randomValue}`; const username = `${firstName[0]}.${lastName}.${randomValue}`;

View File

@@ -1,3 +1,42 @@
//themes
const myTheme = {
default: {
primary: 'hsl(227, 23%, 20%)',
secondary: 'hsl(255, 9%, 69%)',
error: 'hsl(9, 52%, 57%)',
accent: 'hsl(316, 96%, 60%)',
neutral: 'hsl(240, 11%, 8%)',
info: 'hsl(207, 100%, 50%)',
success: 'hsl(100, 57%, 53%)',
warning: 'hsl(50, 98%, 50%)',
'primary-content': 'hsl(0, 0%, 98%)',
'error-content': 'hsl(0, 0%, 98%)',
'base-100': 'hsl(190, 4%, 9%)',
'base-200': 'hsl(190, 4%, 8%)',
'base-300': 'hsl(190, 4%, 5%)',
},
};
const pastelTheme = {
default: {
primary: 'hsl(180, 28%, 65%)',
secondary: 'hsl(21, 54%, 83%)',
error: 'hsl(4, 87%, 74%)',
accent: 'hsl(93, 27%, 73%)',
neutral: 'hsl(38, 31%, 91%)',
info: 'hsl(163, 40%, 79%)',
success: 'hsl(93, 27%, 73%)',
warning: 'hsl(40, 76%, 73%)',
'primary-content': 'hsl(0, 0%, 12%)',
'error-content': 'hsl(0, 0%, 12%)',
'base-100': 'hsl(0, 0%, 85%)',
'base-200': 'hsl(0, 0%, 82%)',
'base-300': 'hsl(0, 0%, 78%)',
'base-400': 'hsl(0, 0%, 75%)',
},
};
/** @type {import('tailwindcss').Config} */ /** @type {import('tailwindcss').Config} */
module.exports = { module.exports = {
content: [ content: [
@@ -13,24 +52,6 @@ module.exports = {
daisyui: { daisyui: {
logs: false, logs: false,
themes: [ themes: [myTheme],
{
default: {
primary: 'hsl(227, 23%, 20%)',
secondary: '#ABA9C3',
error: '#c17c74',
accent: '#fe3bd9',
neutral: '#131520',
info: '#0A7CFF',
success: '#8ACE2B',
warning: '#F9D002',
'primary-content': '#FAF9F6',
'error-content': '#FAF9F6',
'base-100': 'hsl(190, 4%, 9%)',
'base-200': 'hsl(190, 4%, 8%)',
'base-300': 'hsl(190, 4%, 5%)',
},
},
],
}, },
}; };