From 1a3976ccbcadd19b28911c61c82fb27072974cf9 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Sun, 16 Nov 2025 18:32:37 +0100 Subject: [PATCH] Remove unused heartbeat endpoint and storage method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Removed PUT /offers/:offerId/heartbeat endpoint - Removed updateOfferLastSeen() from storage interface and implementations - last_seen column is still in DB but not used for cleanup - Cleanup only uses expires_at, so heartbeat was non-functional 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/app.ts | 33 --------------------------------- src/storage/d1.ts | 8 -------- src/storage/sqlite.ts | 10 ---------- src/storage/types.ts | 7 ------- 4 files changed, 58 deletions(-) diff --git a/src/app.ts b/src/app.ts index b8fffa2..cce9984 100644 --- a/src/app.ts +++ b/src/app.ts @@ -314,39 +314,6 @@ export function createApp(storage: Storage, config: Config) { } }); - /** - * PUT /offers/:offerId/heartbeat - * Update last_seen timestamp for an offer - * Requires authentication and ownership - */ - app.put('/offers/:offerId/heartbeat', authMiddleware, async (c) => { - try { - const offerId = c.req.param('offerId'); - const peerId = getAuthenticatedPeerId(c); - - // Verify ownership - const offer = await storage.getOfferById(offerId); - if (!offer) { - return c.json({ error: 'Offer not found or expired' }, 404); - } - - if (offer.peerId !== peerId) { - return c.json({ error: 'Not authorized to update this offer' }, 403); - } - - const now = Date.now(); - await storage.updateOfferLastSeen(offerId, now); - - return c.json({ - id: offerId, - lastSeen: now - }, 200); - } catch (err) { - console.error('Error updating offer heartbeat:', err); - return c.json({ error: 'Internal server error' }, 500); - } - }); - /** * DELETE /offers/:offerId * Delete a specific offer diff --git a/src/storage/d1.ts b/src/storage/d1.ts index 7c26815..2ec9a60 100644 --- a/src/storage/d1.ts +++ b/src/storage/d1.ts @@ -155,14 +155,6 @@ export class D1Storage implements Storage { return this.rowToOffer(result as any); } - async updateOfferLastSeen(offerId: string, lastSeen: number): Promise { - await this.db.prepare(` - UPDATE offers - SET last_seen = ? - WHERE id = ? AND expires_at > ? - `).bind(lastSeen, offerId, Date.now()).run(); - } - async deleteOffer(offerId: string, ownerPeerId: string): Promise { const result = await this.db.prepare(` DELETE FROM offers diff --git a/src/storage/sqlite.ts b/src/storage/sqlite.ts index 7beb6d4..5c91ea8 100644 --- a/src/storage/sqlite.ts +++ b/src/storage/sqlite.ts @@ -176,16 +176,6 @@ export class SQLiteStorage implements Storage { return this.rowToOffer(row); } - async updateOfferLastSeen(offerId: string, lastSeen: number): Promise { - const stmt = this.db.prepare(` - UPDATE offers - SET last_seen = ? - WHERE id = ? AND expires_at > ? - `); - - stmt.run(lastSeen, offerId, Date.now()); - } - async deleteOffer(offerId: string, ownerPeerId: string): Promise { const stmt = this.db.prepare(` DELETE FROM offers diff --git a/src/storage/types.ts b/src/storage/types.ts index a136327..8fb75b8 100644 --- a/src/storage/types.ts +++ b/src/storage/types.ts @@ -80,13 +80,6 @@ export interface Storage { */ getOfferById(offerId: string): Promise; - /** - * Updates the last_seen timestamp for an offer (heartbeat) - * @param offerId Offer identifier - * @param lastSeen New last_seen timestamp - */ - updateOfferLastSeen(offerId: string, lastSeen: number): Promise; - /** * Deletes an offer (with ownership verification) * @param offerId Offer identifier