Fixed: review add - send add request to api
This commit is contained in:
@ -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));
|
||||
|
@ -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,
|
||||
|
@ -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 = {
|
||||
|
Reference in New Issue
Block a user