Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18,618 changes: 18,618 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@
},
"devDependencies": {
"concurrently": "^8.2.2"
},
"dependencies": {
"@types/mongoose": "^5.11.96",
"mongoose": "^8.15.2"
}
}
}
3 changes: 2 additions & 1 deletion packages/backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import express from 'express';
import cors from 'cors';
import itemsRouter from './routes/items';
import healthRouter from './routes/health';

import calendarRoutes from './routes/calendarRoutes';
const app = express();

// Middleware
Expand All @@ -12,5 +12,6 @@ app.use(express.json());
// Routes
app.use('/api/health', healthRouter);
app.use('/api/items', itemsRouter);
app.use('/api/calendar', calendarRoutes);

export default app;
30 changes: 30 additions & 0 deletions packages/backend/src/controllers/calendarController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Request,Response } from "express";
import CalendarEvent from "../models/CalendarEvent";

export const getAllEvents = async(req: Request, res: Response) => {
try{
const events = await CalendarEvent.find();
res.json(events);
}
catch (error) {
res.status(500).json({ error: 'Failed to fetch events' });
}
};
export const createCalendarEvent = async (req: Request, res: Response) => {
const { title, date, location, participants } = req.body;
if (!title || !date) {
return res.status(400).json({ error: 'Title and date are required' });
}
try{
const event = new CalendarEvent({
title,
date,
location : location || '',
participants:participants || [],
});
await event.save();
res.status(201).json(event);
} catch (error) {
res.status(500).json({ error: 'Failed to create event' });
}
}
6 changes: 4 additions & 2 deletions packages/backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import dotenv from 'dotenv';
dotenv.config();
import path from 'path';



import app from './app';

const PORT = process.env.PORT || 3001;

app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
});
22 changes: 22 additions & 0 deletions packages/backend/src/models/CalendarEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import mongoose from 'mongoose';

const calendarEventSchema = new mongoose.Schema({
title: {
type: String,
required: true,
},
date: {
type: Date,
required: true,
},
location: {
type: String,
required: false,
},
participants: {
type: [String],
required: false,
},
});
const CalendarEvent = mongoose.model('CalendarEvent', calendarEventSchema);
export default CalendarEvent;
13 changes: 13 additions & 0 deletions packages/backend/src/routes/calendarRoutes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import express, { Request, Response } from "express";
import { getAllEvents, createCalendarEvent } from "../controllers/calendarController";

const router = express.Router();
// Route to get all calendar events

router.get("/events", (req: Request, res: Response) => getAllEvents(req, res));
router.post('/', async (req: Request, res: Response) => {
await createCalendarEvent(req, res);
});


export default router;
Binary file modified packages/frontend/.env.development
Binary file not shown.
Loading