get sessions by projectId

This commit is contained in:
Storme-bit
2026-04-14 01:16:59 -07:00
parent 30aaad6f77
commit 271a396ef5

View File

@@ -30,17 +30,17 @@ app.get('/health', (req, res) => {
/************************************ */ /************************************ */
// Creates a new session with an external ID and optional metadata // Creates a new session with an external ID and optional metadata
app.post('/sessions', (req, res) => { app.get('/sessions', (req, res) => {
const {externalId, metadata} = req.body; const {
if (!externalId) { limit = EPISODIC.DEFAULT_PAGE_SIZE,
return res.status(400).json({ error: 'externalId is required' }); offset = EPISODIC.DEFAULT_OFFSET,
} projectId
try { } = req.query;
const session = episodic.createSession(externalId, metadata);
res.status(201).json(session); const parsedProjectId = projectId && projectId !== 'null' ? Number(projectId) : null;
} catch (err) {
res.status(409).json({ error: 'Session already exists', detail: err.message }); const sessions = episodic.getSessions(Number(limit), Number(offset), parsedProjectId);
} res.json(sessions);
}); });
app.get('/sessions', (req, res) => { app.get('/sessions', (req, res) => {