sessions router mounted onto root
This commit is contained in:
@@ -22,19 +22,4 @@ router.post('/', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/sessions/:sessionId/history', async (req, res) => {
|
||||
const { sessionId } = req.params;
|
||||
const { limit = 20, offset = 0 } = req.query;
|
||||
|
||||
try {
|
||||
const session = await memory.getSessionByExternalId(sessionId);
|
||||
if (!session) return res.status(404).json({ error: 'Session not found' });
|
||||
|
||||
const history = await memory.getSessionHistory(session.id, Number(limit), Number(offset));
|
||||
res.json({ sessionId, episodes: history });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
21
packages/orchestration-service/src/routes/sessions.js
Normal file
21
packages/orchestration-service/src/routes/sessions.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const { Router } = require('express');
|
||||
const memory = require('../services/memory');
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/:sessionId/history', async (req, res) => {
|
||||
const { sessionId } = req.params;
|
||||
const { limit = 20, offset = 0 } = req.query;
|
||||
|
||||
try {
|
||||
const session = await memory.getSessionByExternalId(sessionId);
|
||||
if (!session) return res.status(404).json({ error: 'Session not found' });
|
||||
|
||||
const history = await memory.getSessionHistory(session.id, Number(limit), Number(offset));
|
||||
res.json({ sessionId, episodes: history });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user