-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(seeders): add learner, tutor, and tutor services seeder
- Loading branch information
Showing
13 changed files
with
405 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
PORT= | ||
FIREBASE_SERVICE_ACCOUNT_KEY= | ||
FIREBASE_DATABASE_URL= | ||
GCS_BUCKET_NAME= | ||
GCS_BUCKET_NAME= | ||
GROQ_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
import type { Learner, Tutor } from "./types"; | ||
|
||
// https://stackoverflow.com/a/69328045/13838937 | ||
// To make a property non-optional | ||
type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] }; | ||
|
||
type LearnerWithId = WithRequired<Learner, "id">; | ||
type TutorWithId = WithRequired<Tutor, "id">; | ||
|
||
declare global { | ||
namespace Express { | ||
interface Request { | ||
learner: Learner; | ||
tutor: Tutor; | ||
learner: LearnerWithId; | ||
tutor: TutorWithId; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { checkSubjectExists } from "@services/subject.service"; | ||
import { checkTutorExists } from "@services/tutor.service"; | ||
import { z } from "zod"; | ||
|
||
export const tutorServiceSchema = z.object({ | ||
id: z.string().optional(), | ||
tutorId: z.string().superRefine(async (tutorId, ctx) => { | ||
const exists = await checkTutorExists(tutorId); | ||
if (!exists) { | ||
ctx.addIssue({ | ||
code: z.ZodIssueCode.custom, | ||
message: "Tutor does not exist", | ||
}); | ||
} | ||
}), | ||
subjectId: z.string().superRefine(async (subjectId, ctx) => { | ||
const exists = await checkSubjectExists(subjectId); | ||
if (!exists) { | ||
ctx.addIssue({ | ||
code: z.ZodIssueCode.custom, | ||
message: "Subject does not exist", | ||
}); | ||
} | ||
}), | ||
// About the tutor's experience with the subject | ||
aboutYou: z.string(), | ||
// Tutor's teaching methodology | ||
teachingMethodology: z.string(), | ||
hourlyRate: z.number(), | ||
createdAt: z.date(), | ||
updatedAt: z.date().optional(), | ||
}); |
Oops, something went wrong.