mcp-quiz-server
Version:
🧠AI-Powered Quiz Management via Model Context Protocol (MCP) - Create, manage, and take quizzes directly from VS Code, Claude, and other AI agents.
109 lines (108 loc) • 4.13 kB
JavaScript
;
/**
* @fileoverview Dashboard Routes - MVVM Architecture Entry Point
* @version 2.0.0
* @since 2025-08-04
* @module DashboardRoutes
* @description Modern dashboard routes with API-first architecture and progressive enhancement
* @contributors Claude Code Agent
* @requirements REQ-AUTH-001, REQ-DASH-001 (User Dashboard)
* @architecture MVVM with progressive enhancement, static HTML + TypeScript components
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DashboardRoutes = void 0;
exports.createDashboardRoutes = createDashboardRoutes;
const express = __importStar(require("express"));
const DashboardApiRoutes_1 = require("./DashboardApiRoutes");
/**
* Dashboard Routes Handler - MVVM Architecture
*
* @description Modern dashboard implementation using:
* - Static HTML base (public/pages/dashboard.html)
* - Progressive enhancement (public/js/components/Dashboard.ts)
* - API-first data layer (DashboardApiRoutes.ts)
* - Unified authentication (ApiClient.ts + AuthManager.ts)
*/
class DashboardRoutes {
constructor(authService) {
this.router = express.Router();
this.authService = authService;
this.setupRoutes();
}
getRouter() {
return this.router;
}
/**
* Setup unified dashboard routes
*
* Architecture:
* - All routes serve the same progressive enhancement HTML base
* - TypeScript components handle client-side routing and state
* - API endpoints provide data via DashboardApiRoutes
*/
setupRoutes() {
// Mount API routes (all /dashboard/api/* endpoints)
this.router.use('/', (0, DashboardApiRoutes_1.createDashboardApiRoutes)(this.authService));
// Legacy redirects for backward compatibility
this.setupLegacyRedirects();
}
/**
* Setup legacy compatibility redirects
*/
setupLegacyRedirects() {
// Legacy API endpoints - redirect to new structure
this.router.get('/api/user-info', (req, res) => {
res.redirect(301, '/dashboard/api/user');
});
this.router.get('/api/user-quizzes', (req, res) => {
res.redirect(301, '/dashboard/api/quizzes');
});
this.router.get('/api/dashboard-stats', (req, res) => {
res.redirect(301, '/dashboard/api/stats');
});
}
}
exports.DashboardRoutes = DashboardRoutes;
/**
* Factory function to create dashboard routes
*
* @param authService - JWT authentication service
* @returns Express router with all dashboard routes
*/
function createDashboardRoutes(authService) {
const dashboardRoutes = new DashboardRoutes(authService);
return dashboardRoutes.getRouter();
}