added: grade, subject and chapter in new chat, fixed that shitty card bug

This commit is contained in:
2026-08-18 04:44:10 -04:00
parent ab88ae30f1
commit 93a35a7343
24 changed files with 2683 additions and 66 deletions
+58
View File
@@ -0,0 +1,58 @@
import express from "express";
import { listSessions, getSession, deleteSession, clearMessages, createSession } from "../stores/sessionStore.js";
const router = express.Router();
/**
* GET /api/sessions — List all sessions
*/
router.get("/", (_req, res) => {
const sessions = listSessions();
res.json(sessions);
});
/**
* POST /api/sessions — Create a new session
*/
router.post("/", (req, res) => {
const { grade, subject, chapter } = req.body;
const session = createSession(grade, subject, chapter);
res.status(201).json(session);
});
/**
* GET /api/sessions/:id — Get a single session
*/
router.get("/:id", (req, res) => {
const session = getSession(req.params.id);
if (!session) {
return res.status(404).json({ error: "Session not found" });
}
res.json(session);
});
/**
* DELETE /api/sessions/:id — Delete a session
*/
router.delete("/:id", (req, res) => {
const deleted = deleteSession(req.params.id);
if (!deleted) {
return res.status(404).json({ error: "Session not found" });
}
res.json({ message: "Session deleted", id: req.params.id });
});
/**
* PATCH /api/sessions/:id/clear — Clear messages but keep session
*/
router.patch("/:id/clear", (req, res) => {
const { id } = req.params;
const session = getSession(id);
if (!session) {
return res.status(404).json({ error: "Session not found" });
}
clearMessages(id);
res.json({ message: "Messages cleared", id });
});
export default router;