Fixed: review add - send add request to api

This commit is contained in:
2024-05-15 01:35:52 +02:00
parent a57a059c2a
commit 986aca3931
8 changed files with 20 additions and 4 deletions

View File

@ -18,6 +18,7 @@ new Docs(
export async function add_post(req: Request, res: Response) {
try {
const data: IReview = req.body;
data.user_id = res.locals.user._id
const review = new Review(data);
await review.save();
res.status(201).json(Log.info(201, "review was added", review));

View File

@ -28,6 +28,14 @@ const schema = new Schema<IReview | any>(
type: Boolean,
required: true,
},
beer_id: {
type: String,
required: true,
},
user_id: {
type: String,
required: true,
}
},
{
timestamps: true,

View File

@ -20,6 +20,7 @@ export const add = yup.object({
packaging: yup.number().min(1).max(5).required(),
sourness: yup.boolean().required(),
would_again: yup.boolean().required(),
user_id: yup.string().notRequired()
});
export interface IReview extends yup.InferType<typeof add>, mongooseAddition {}
export const addExam: IReview = {