Backend: code formatted

This commit is contained in:
2024-05-12 21:25:52 +02:00
parent fa25015472
commit bf791db47f
26 changed files with 574 additions and 469 deletions

View File

@ -1,5 +1,5 @@
import * as yup from 'yup'
import mongoose, { Schema } from 'mongoose'
import * as yup from "yup";
import mongoose, { Schema } from "mongoose";
interface mongooseAddition {
_id?: Schema.Types.ObjectId;
@ -7,39 +7,36 @@ interface mongooseAddition {
updatedAt?: Schema.Types.Date;
}
let objectIdSchema = yup.string().test(
'is-objectId',
'Invalid ObjectId',
(value: any) => mongoose.Types.ObjectId.isValid(value)
)
let objectIdSchema = yup
.string()
.test("is-objectId", "Invalid ObjectId", (value: any) => mongoose.Types.ObjectId.isValid(value));
// Add
export const add = yup.object({
beer_id: objectIdSchema,
foam: yup.number().min(1).max(3).required(),
bitter_sweetness: yup.number().min(1).max(5).required(),
taste: yup.number().min(1).max(5).required(),
packaging: yup.number().min(1).max(5).required(),
sourness: yup.boolean().required(),
would_again: yup.boolean().required()
})
beer_id: objectIdSchema,
foam: yup.number().min(1).max(3).required(),
bitter_sweetness: yup.number().min(1).max(5).required(),
taste: yup.number().min(1).max(5).required(),
packaging: yup.number().min(1).max(5).required(),
sourness: yup.boolean().required(),
would_again: yup.boolean().required(),
});
export interface IReview extends yup.InferType<typeof add>, mongooseAddition {}
export const addExam: IReview = {
beer_id: '6352b303b71cb62222f39895',
foam: 3,
bitter_sweetness: 2,
taste: 5,
packaging: 3,
sourness: false,
would_again: true
}
beer_id: "6352b303b71cb62222f39895",
foam: 3,
bitter_sweetness: 2,
taste: 5,
packaging: 3,
sourness: false,
would_again: true,
};
// Remove
export const del = yup.object({
_id: objectIdSchema.required()
})
_id: objectIdSchema.required(),
});
export interface IDel extends yup.InferType<typeof del> {}
export const delExam: IDel = {
_id: '6352b303b71cb62222f39895'
_id: "6352b303b71cb62222f39895",
};