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
|
// 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) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user