fix: implement upsert behavior for service creation

When a service is republished (e.g., for TTL refresh), the old service
is now deleted before creating a new one, preventing UNIQUE constraint
errors on (username, service_fqn).

Changes:
- Query for existing service before creation
- Delete existing service if found
- Create new service with same username/serviceFqn

This enables the client's TTL auto-refresh feature to work correctly.
This commit is contained in:
2025-12-06 13:04:45 +01:00
parent 52cf734858
commit 1257867dff

View File

@@ -61,7 +61,7 @@ export function createApp(storage: Storage, config: Config) {
/**
* POST /register
* Register a new peer (still needed for peer ID generation)
* Register a new peer
*/
app.post('/register', async (c) => {
try {