mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 18:52:06 +00:00
feat: client app can now upload images for beer posts
Updated seed to incorporate cloudinary images, downgraded multer to recent LTS, update tsconfig to allow spread operator usage on FileList.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { BeerPost, User } from '@prisma/client';
|
||||
import DBClient from '../../DBClient';
|
||||
import imageUrls from '../util/imageUrls';
|
||||
|
||||
interface CreateNewBeerImagesArgs {
|
||||
numberOfImages: number;
|
||||
@@ -31,9 +32,10 @@ const createNewBeerImages = async ({
|
||||
const user = users[Math.floor(Math.random() * users.length)];
|
||||
const caption = faker.lorem.sentence();
|
||||
const alt = faker.lorem.sentence();
|
||||
const path = imageUrls[Math.floor(Math.random() * imageUrls.length)];
|
||||
|
||||
beerImageData.push({
|
||||
path: 'https://picsum.photos/5000/5000',
|
||||
path,
|
||||
alt,
|
||||
caption,
|
||||
beerPostId: beerPost.id,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { BreweryPost, User } from '@prisma/client';
|
||||
import DBClient from '../../DBClient';
|
||||
import imageUrls from '../util/imageUrls';
|
||||
|
||||
interface CreateBreweryImagesArgs {
|
||||
numberOfImages: number;
|
||||
@@ -32,9 +33,10 @@ const createNewBreweryImages = async ({
|
||||
for (let i = 0; i < numberOfImages; i++) {
|
||||
const breweryPost = breweryPosts[Math.floor(Math.random() * breweryPosts.length)];
|
||||
const user = users[Math.floor(Math.random() * users.length)];
|
||||
const path = imageUrls[Math.floor(Math.random() * imageUrls.length)];
|
||||
|
||||
breweryImageData.push({
|
||||
path: 'https://picsum.photos/5000/5000',
|
||||
path,
|
||||
alt: 'Placeholder brewery image.',
|
||||
caption: 'Placeholder brewery image caption.',
|
||||
breweryPostId: breweryPost.id,
|
||||
|
||||
9
src/prisma/seed/util/imageUrls.ts
Normal file
9
src/prisma/seed/util/imageUrls.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
const imageUrls = [
|
||||
'https://res.cloudinary.com/dxie9b7na/image/upload/v1683482214/cld-sample.jpg',
|
||||
'https://res.cloudinary.com/dxie9b7na/image/upload/v1683482214/cld-sample-2.jpg',
|
||||
'https://res.cloudinary.com/dxie9b7na/image/upload/v1683482214/cld-sample-3.jpg',
|
||||
'https://res.cloudinary.com/dxie9b7na/image/upload/v1683482214/cld-sample-4.jpg',
|
||||
'https://res.cloudinary.com/dxie9b7na/image/upload/v1683482214/cld-sample-5.jpg',
|
||||
] as const;
|
||||
|
||||
export default imageUrls;
|
||||
Reference in New Issue
Block a user