123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import { z } from "zod";
- import { DbShema } from "../db-shema.js";
- class QuestionsApiShema {
- public ZCreateNewQuestion = {
- req: {
- data: z.object({
- text: DbShema.ZQuestions.shape.q_text,
- answers: DbShema.ZQuestions.shape.answers,
- difficulty: DbShema.ZQuestions.shape.difficulty,
- categories: z.array(DbShema.ZCategories.shape.category_id),
- }),
- questionId: z.number().optional(),
- },
- };
- //
- public ZCategory = z.object({
- category_id: DbShema.ZCategories.shape.category_id,
- name: DbShema.ZCategories.shape.name,
- description: DbShema.ZCategories.shape.description,
- category_questions_count:
- DbShema.ZRemainingCategoryQuestions.shape.category_questions_count,
- max_used_category_questions:
- DbShema.ZRemainingCategoryQuestions.shape.max_used_category_questions,
- questions_remained:
- DbShema.ZRemainingCategoryQuestions.shape.questions_remained,
- is_shortage: z.boolean(),
- });
- public ZGetCategories = {
- res: z.array(this.ZCategory),
- };
- //
- public ZCreateNewCategory = {
- req: z.object({
- name: DbShema.ZCategories.shape.name,
- description: DbShema.ZCategories.shape.description,
- }),
- };
- public ZGetQuestionsByCategory = {
- req: z.object({
- categoryId: DbShema.ZCategories.shape.category_id,
- }),
- res: z.object({
- questions: z.array(DbShema.ZQuestions),
- }),
- };
- public ZGetQuestionCategories = {
- req: z.object({
- questionId: DbShema.ZQuestions.shape.question_id,
- }),
- res: z.object({
- categories: z.array(z.number()),
- }),
- };
- public ZDeleteQuestion = {
- req: z.object({
- questionId: DbShema.ZQuestions.shape.question_id,
- }),
- };
- }
- export default new QuestionsApiShema();
|