get sessions by projectId
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user