import express from 'express'; import { meRoute, calendarViewRoute, eventsRoute, authStatusRoute, loginRoute, createEventRoute, editEventRoute, messagesRoute, driveRoute } from '../routes/index.ts'; import { AuthManager } from '../auth/index.ts'; export default class MicrosoftGraphServer { private app = express(); private auth: AuthManager; constructor(authManager: AuthManager) { this.auth = authManager; // Add JSON body parser this.app.use(express.json()); // Register routes this.app.use('/auth', authStatusRoute(this.auth)); this.app.use('/login', loginRoute(this.auth)); this.app.use('/me', meRoute(this.auth)); this.app.use('/me/events', eventsRoute(this.auth)); this.app.use('/me/calendar-view', calendarViewRoute(this.auth)); this.app.use('/events/create', createEventRoute(this.auth)); this.app.use('/events/edit', editEventRoute(this.auth)); this.app.use('/me/messages', messagesRoute(this.auth)); this.app.use('/me/drive', driveRoute(this.auth)); } async start(port = parseInt(process.env.PORT || '3000')) { this.app.listen(port, () => console.log(`Server running on http://localhost:${port}`)); } }