mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-10 02:43:24 +00:00
Add upsert behavior to service creation
- Delete existing service before creating new one - Prevents UNIQUE constraint error on (username, service_fqn) - Enables seamless service republishing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -217,6 +217,15 @@ export function createApp(storage: Storage, config: Config) {
|
|||||||
return c.json({ error: 'Invalid signature for username' }, 403);
|
return c.json({ error: 'Invalid signature for username' }, 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete existing service if one exists (upsert behavior)
|
||||||
|
const existingUuid = await storage.queryService(username, serviceFqn);
|
||||||
|
if (existingUuid) {
|
||||||
|
const existingService = await storage.getServiceByUuid(existingUuid);
|
||||||
|
if (existingService) {
|
||||||
|
await storage.deleteService(existingService.id, username);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Validate SDP
|
// Validate SDP
|
||||||
if (typeof sdp !== 'string' || sdp.length === 0) {
|
if (typeof sdp !== 'string' || sdp.length === 0) {
|
||||||
return c.json({ error: 'Invalid SDP' }, 400);
|
return c.json({ error: 'Invalid SDP' }, 400);
|
||||||
|
|||||||
Reference in New Issue
Block a user