Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobc2700 committed Aug 12, 2024
1 parent fa205e1 commit 4085789
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.
18 changes: 4 additions & 14 deletions src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import {
EventAttendanceValidator,
} from "./services/events/events-schema";
import { RoleValidator, RoleSchema } from "./services/auth/auth-schema";
import {
RegistrationSchema,
RegistrationValidator,
} from "./services/registration/registration-schema";
import { RegistrationSchema } from "./services/registration/registration-schema";
import {
SubscriptionSchemaValidator,
SubscriptionSchema,
Expand All @@ -24,10 +21,7 @@ import {
NotificationsSchema,
NotificationsValidator,
} from "./services/notifications/notifications-schema";
import {
SpeakerSchema,
SpeakerValidator,
} from "./services/speakers/speakers-schema";
import { SpeakerSchema } from "./services/speakers/speakers-schema";
import {
SponsorAuthSchema,
SponsorAuthValidator,
Expand Down Expand Up @@ -86,11 +80,7 @@ export const Database = {
SubscriptionSchema,
SubscriptionSchemaValidator
),
REGISTRATION: initializeModel(
"registration",
RegistrationSchema,
RegistrationValidator
),
REGISTRATION: mongoose.model("registration", RegistrationSchema),
NOTIFICATIONS: initializeModel(
"notifications",
NotificationsSchema,
Expand All @@ -101,7 +91,7 @@ export const Database = {
SponsorAuthSchema,
SponsorAuthValidator
),
SPEAKERS: initializeModel("speakers", SpeakerSchema, SpeakerValidator),
SPEAKERS: mongoose.model("speakers", SpeakerSchema),
CORPORATE: initializeModel(
"corporate",
CorporateSchema,
Expand Down
2 changes: 1 addition & 1 deletion src/services/speakers/speakers-router.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Router } from "express";
import { StatusCodes } from "http-status-codes";
import { SpeakerValidator } from "./speakers-schema";
import { SpeakerValidator } from "./speakers-validators";
import { Database } from "../../database";
import RoleChecker from "../../middleware/role-checker";
import { Role } from "../auth/auth-models";
Expand Down
12 changes: 0 additions & 12 deletions src/services/speakers/speakers-schema.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
import { Schema } from "mongoose";
import { z } from "zod";
import { v4 as uuidv4 } from "uuid";

// Zod schema for speaker
export const SpeakerValidator = z.object({
speakerId: z.coerce.string().default(() => uuidv4()),
name: z.string(),
title: z.string(),
bio: z.string(),
eventTitle: z.string(),
eventDescription: z.string(),
imgUrl: z.string(),
});

// Mongoose schema for speaker
export const SpeakerSchema = new Schema({
speakerId: {
Expand Down
13 changes: 13 additions & 0 deletions src/services/speakers/speakers-validators.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { z } from "zod";
import { v4 as uuidv4 } from "uuid";

// Zod schema for speaker
export const SpeakerValidator = z.object({
speakerId: z.coerce.string().default(() => uuidv4()),
name: z.string(),
title: z.string(),
bio: z.string(),
eventTitle: z.string(),
eventDescription: z.string(),
imgUrl: z.string(),
});

0 comments on commit 4085789

Please sign in to comment.