Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions server/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,23 @@ export async function registerRoutes(
const tellabotMap = new Map(tellabotServices.map((s: any) => [s.name, s]));
const enriched = dbServices.map(svc => {
const tb = tellabotMap.get(svc.name);
return {
...svc,
available: tb ? parseInt(tb.otp_available) : 0,
costPrice: tb ? tb.price : null,
};
// Strip internal fields (costPrice, upstreamPrice, priceLocked, internal id) from public response
const { costPrice: _cp, upstreamPrice: _up, priceLocked: _pl, id: _id, ...publicSvc } = svc as any;
return {
...publicSvc,
available: tb ? parseInt(tb.otp_available) : 0,
};
});
res.json(enriched);
} catch (err) {
// Fallback to DB
const dbServices = await storage.getAllServices();
res.json(dbServices);
// Strip internal fields on fallback too
const safe = dbServices.map((s: any) => {
const { costPrice: _cp, upstreamPrice: _up, priceLocked: _pl, id: _id, ...rest } = s;
return rest;
});
res.json(safe);
}
});

Expand Down
Loading