Skip to content

Commit

Permalink
hopefully done events
Browse files Browse the repository at this point in the history
  • Loading branch information
riyap committed Apr 9, 2024
1 parent fd4ede4 commit 01a61c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/services/events/events-router.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Router } from "express";
import { StatusCodes } from "http-status-codes";
import { Event, EventValidator } from "./events-schema";
import { EventValidator } from "./events-schema";
import { Database } from "../../database";

const eventRouter = Router();
// authRouter.get("/", async (req, res) => {
Expand All @@ -9,7 +10,7 @@ const eventRouter = Router();
eventRouter.post("/events", async (req, res, next) => {
try {
const validatedData = EventValidator.parse(req.body);
const event = new Event(validatedData);
const event = new Database.EVENT(validatedData);
await event.save();
return res.status(StatusCodes.CREATED).json(event);
} catch (error) {
Expand Down
8 changes: 4 additions & 4 deletions src/services/events/events-schema.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import mongoose from "mongoose";
// import mongoose from "mongoose";
import { Schema } from "mongoose";
import { z } from "zod";

export const EventValidator = z.object({
eventId: z.coerce.string().cuid2(),
name: z.string(),
startTime: z.coerce.string().datetime(),
endTime: z.coerce.string().datetime(),
startTime: z.coerce.date(),
endTime: z.coerce.date(),
});

export const EventSchema = new Schema({
Expand All @@ -28,4 +28,4 @@ export const EventSchema = new Schema({
required: true,
},
});
export const Event = mongoose.model("Event", EventSchema);
// export const Event = mongoose.model("Event", EventSchema);

0 comments on commit 01a61c9

Please sign in to comment.