mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-10 10:53:24 +00:00
Add /leave endpoint to end sessions
- Add POST /leave endpoint that deletes offers by code - Allows either peer to end the session - Returns success confirmation This enables proper session cleanup when either peer wants to explicitly end the connection. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
23
src/app.ts
23
src/app.ts
@@ -190,5 +190,28 @@ export function createApp(storage: Storage, config: AppConfig) {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* POST /leave
|
||||
* Ends a session by deleting the offer
|
||||
* Body: { code: string }
|
||||
*/
|
||||
app.post('/leave', async (c) => {
|
||||
try {
|
||||
const body = await c.req.json();
|
||||
const { code } = body;
|
||||
|
||||
if (!code || typeof code !== 'string') {
|
||||
return c.json({ error: 'Missing or invalid required parameter: code' }, 400);
|
||||
}
|
||||
|
||||
await storage.deleteOffer(code);
|
||||
|
||||
return c.json({ success: true }, 200);
|
||||
} catch (err) {
|
||||
console.error('Error leaving session:', err);
|
||||
return c.json({ error: 'Internal server error' }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user