mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Update: all queries involving image now use ImageQueryValidationSchema
This commit is contained in:
@@ -36,7 +36,16 @@ const createNewBeerPost = ({
|
||||
ibu: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
beerImages: { select: { id: true, path: true, caption: true, alt: true } },
|
||||
beerImages: {
|
||||
select: {
|
||||
alt: true,
|
||||
path: true,
|
||||
caption: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
},
|
||||
brewery: { select: { id: true, name: true } },
|
||||
style: { select: { id: true, name: true, description: true } },
|
||||
postedBy: { select: { id: true, username: true } },
|
||||
|
||||
@@ -19,7 +19,16 @@ const deleteBeerPostById = ({
|
||||
id: true,
|
||||
name: true,
|
||||
updatedAt: true,
|
||||
beerImages: { select: { id: true, path: true, caption: true, alt: true } },
|
||||
beerImages: {
|
||||
select: {
|
||||
alt: true,
|
||||
path: true,
|
||||
caption: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
},
|
||||
style: { select: { id: true, name: true, description: true } },
|
||||
postedBy: { select: { id: true, username: true } },
|
||||
brewery: { select: { id: true, name: true } },
|
||||
|
||||
@@ -25,7 +25,16 @@ const editBeerPostById = ({
|
||||
ibu: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
beerImages: { select: { id: true, path: true, caption: true, alt: true } },
|
||||
beerImages: {
|
||||
select: {
|
||||
alt: true,
|
||||
path: true,
|
||||
caption: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
},
|
||||
brewery: { select: { id: true, name: true } },
|
||||
style: { select: { id: true, name: true, description: true } },
|
||||
postedBy: { select: { id: true, username: true } },
|
||||
|
||||
@@ -25,7 +25,16 @@ const getAllBeerPosts = ({
|
||||
style: { select: { name: true, id: true, description: true } },
|
||||
brewery: { select: { name: true, id: true } },
|
||||
postedBy: { select: { id: true, username: true } },
|
||||
beerImages: { select: { path: true, caption: true, id: true, alt: true } },
|
||||
beerImages: {
|
||||
select: {
|
||||
alt: true,
|
||||
path: true,
|
||||
caption: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
take: pageSize,
|
||||
skip: (pageNum - 1) * pageSize,
|
||||
|
||||
@@ -19,7 +19,16 @@ const getBeerPostById = async (
|
||||
postedBy: { select: { username: true, id: true } },
|
||||
brewery: { select: { name: true, id: true } },
|
||||
style: { select: { name: true, id: true, description: true } },
|
||||
beerImages: { select: { alt: true, path: true, caption: true, id: true } },
|
||||
beerImages: {
|
||||
select: {
|
||||
alt: true,
|
||||
path: true,
|
||||
caption: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
where: { id },
|
||||
});
|
||||
|
||||
@@ -28,7 +28,16 @@ const getBeerPostsByBeerStyleId = async ({
|
||||
postedBy: { select: { username: true, id: true } },
|
||||
brewery: { select: { name: true, id: true } },
|
||||
style: { select: { name: true, id: true, description: true } },
|
||||
beerImages: { select: { alt: true, path: true, caption: true, id: true } },
|
||||
beerImages: {
|
||||
select: {
|
||||
alt: true,
|
||||
path: true,
|
||||
caption: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -28,7 +28,16 @@ const getBeerPostsByBeerStyleId = async ({
|
||||
postedBy: { select: { username: true, id: true } },
|
||||
brewery: { select: { name: true, id: true } },
|
||||
style: { select: { name: true, id: true, description: true } },
|
||||
beerImages: { select: { alt: true, path: true, caption: true, id: true } },
|
||||
beerImages: {
|
||||
select: {
|
||||
alt: true,
|
||||
path: true,
|
||||
caption: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -37,7 +37,16 @@ const getBeerRecommendations = async ({
|
||||
style: { select: { name: true, id: true, description: true } },
|
||||
brewery: { select: { name: true, id: true } },
|
||||
postedBy: { select: { id: true, username: true } },
|
||||
beerImages: { select: { path: true, caption: true, id: true, alt: true } },
|
||||
beerImages: {
|
||||
select: {
|
||||
alt: true,
|
||||
path: true,
|
||||
caption: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
take,
|
||||
skip,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import ImageQueryValidationSchema from '@/services/schema/ImageSchema/ImageQueryValidationSchema';
|
||||
import { z } from 'zod';
|
||||
|
||||
const BeerPostQueryResult = z.object({
|
||||
@@ -5,9 +6,7 @@ const BeerPostQueryResult = z.object({
|
||||
name: z.string(),
|
||||
brewery: z.object({ id: z.string(), name: z.string() }),
|
||||
description: z.string(),
|
||||
beerImages: z.array(
|
||||
z.object({ path: z.string(), caption: z.string(), id: z.string(), alt: z.string() }),
|
||||
),
|
||||
beerImages: z.array(ImageQueryValidationSchema),
|
||||
ibu: z.number(),
|
||||
abv: z.number(),
|
||||
style: z.object({ id: z.string(), name: z.string(), description: z.string() }),
|
||||
|
||||
@@ -37,7 +37,16 @@ const createNewBreweryPost = async ({
|
||||
createdAt: true,
|
||||
dateEstablished: true,
|
||||
postedBy: { select: { id: true, username: true } },
|
||||
breweryImages: { select: { path: true, caption: true, id: true, alt: true } },
|
||||
breweryImages: {
|
||||
select: {
|
||||
path: true,
|
||||
caption: true,
|
||||
id: true,
|
||||
alt: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
},
|
||||
location: {
|
||||
select: {
|
||||
city: true,
|
||||
|
||||
@@ -29,7 +29,16 @@ const getAllBreweryPosts = async ({
|
||||
description: true,
|
||||
name: true,
|
||||
postedBy: { select: { username: true, id: true } },
|
||||
breweryImages: { select: { path: true, caption: true, id: true, alt: true } },
|
||||
breweryImages: {
|
||||
select: {
|
||||
path: true,
|
||||
caption: true,
|
||||
id: true,
|
||||
alt: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
},
|
||||
createdAt: true,
|
||||
dateEstablished: true,
|
||||
},
|
||||
|
||||
@@ -19,7 +19,16 @@ const getBreweryPostById = async (id: string) => {
|
||||
},
|
||||
description: true,
|
||||
name: true,
|
||||
breweryImages: { select: { path: true, caption: true, id: true, alt: true } },
|
||||
breweryImages: {
|
||||
select: {
|
||||
path: true,
|
||||
caption: true,
|
||||
id: true,
|
||||
alt: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
},
|
||||
postedBy: { select: { username: true, id: true } },
|
||||
createdAt: true,
|
||||
dateEstablished: true,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import ImageQueryValidationSchema from '@/services/schema/ImageSchema/ImageQueryValidationSchema';
|
||||
import { z } from 'zod';
|
||||
|
||||
const BreweryPostQueryResult = z.object({
|
||||
@@ -12,9 +13,7 @@ const BreweryPostQueryResult = z.object({
|
||||
stateOrProvince: z.string().nullable(),
|
||||
}),
|
||||
postedBy: z.object({ id: z.string(), username: z.string() }),
|
||||
breweryImages: z.array(
|
||||
z.object({ path: z.string(), caption: z.string(), id: z.string(), alt: z.string() }),
|
||||
),
|
||||
breweryImages: z.array(ImageQueryValidationSchema),
|
||||
createdAt: z.coerce.date(),
|
||||
dateEstablished: z.coerce.date(),
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import ImageQueryValidationSchema from '@/services/schema/ImageSchema/ImageQueryValidationSchema';
|
||||
import { z } from 'zod';
|
||||
|
||||
const GetUserSchema = z.object({
|
||||
@@ -12,16 +13,7 @@ const GetUserSchema = z.object({
|
||||
accountIsVerified: z.boolean(),
|
||||
role: z.enum(['USER', 'ADMIN']),
|
||||
bio: z.string().nullable(),
|
||||
userAvatar: z
|
||||
.object({
|
||||
id: z.string().cuid(),
|
||||
path: z.string().url(),
|
||||
alt: z.string(),
|
||||
caption: z.string(),
|
||||
createdAt: z.coerce.date(),
|
||||
updatedAt: z.coerce.date().nullable(),
|
||||
})
|
||||
.nullable(),
|
||||
userAvatar: ImageQueryValidationSchema.nullable(),
|
||||
});
|
||||
|
||||
export default GetUserSchema;
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
import { z } from 'zod';
|
||||
import ImageQueryValidationSchema from '../ImageSchema/ImageQueryValidationSchema';
|
||||
|
||||
const CommentQueryResult = z.object({
|
||||
id: z.string().cuid(),
|
||||
content: z.string().min(1).max(500),
|
||||
rating: z.number().int().min(1).max(5),
|
||||
createdAt: z.coerce.date(),
|
||||
updatedAt: z.coerce.date().nullable(),
|
||||
postedBy: z.object({
|
||||
id: z.string().cuid(),
|
||||
username: z.string().min(1).max(50),
|
||||
userAvatar: z
|
||||
.object({
|
||||
id: z.string().cuid(),
|
||||
path: z.string().url(),
|
||||
alt: z.string().min(1).max(50),
|
||||
caption: z.string().min(1).max(50),
|
||||
})
|
||||
.nullable(),
|
||||
userAvatar: ImageQueryValidationSchema.nullable(),
|
||||
}),
|
||||
updatedAt: z.coerce.date().nullable(),
|
||||
});
|
||||
|
||||
export default CommentQueryResult;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
const ImageQueryValidationSchema = z.object({
|
||||
id: z.string().cuid(),
|
||||
path: z.string().url(),
|
||||
alt: z.string(),
|
||||
caption: z.string(),
|
||||
createdAt: z.coerce.date(),
|
||||
updatedAt: z.coerce.date().nullable(),
|
||||
});
|
||||
|
||||
export default ImageQueryValidationSchema;
|
||||
Reference in New Issue
Block a user