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
app.post('/sessions', (req, res) => {
const {externalId, metadata} = req.body;
if (!externalId) {
return res.status(400).json({ error: 'externalId is required' });
}
try {
const session = episodic.createSession(externalId, metadata);
res.status(201).json(session);
} catch (err) {
res.status(409).json({ error: 'Session already exists', detail: err.message });
}
app.get('/sessions', (req, res) => {
const {
limit = EPISODIC.DEFAULT_PAGE_SIZE,
offset = EPISODIC.DEFAULT_OFFSET,
projectId
} = req.query;
const parsedProjectId = projectId && projectId !== 'null' ? Number(projectId) : null;
const sessions = episodic.getSessions(Number(limit), Number(offset), parsedProjectId);
res.json(sessions);
});
app.get('/sessions', (req, res) => {