Add vertical bar chart UI with Hono mock server

This commit is contained in:
2026-06-22 18:50:24 +05:30
parent 335cdfdea8
commit 0d8dbf1368
5 changed files with 186 additions and 4 deletions
+27
View File
@@ -0,0 +1,27 @@
import { serve } from '@hono/node-server';
import { serveStatic } from '@hono/node-server/serve-static';
import { Hono } from 'hono';
const counters = {
'zone-a': 10,
'zone-b': 15,
'zone-c': 20,
};
const app = new Hono();
app.get('/api/v1/zones/:zoneId/primary/temperature', (c) => {
const zoneId = c.req.param('zoneId');
if (!(zoneId in counters)) counters[zoneId] = 10;
const value = counters[zoneId];
counters[zoneId] += Math.floor(Math.random() * 3) + 3;
return c.json({ value });
});
app.use('/src/*', serveStatic({ root: '.' }));
app.get('/', serveStatic({ path: './index.html', root: '.' }));
serve({ fetch: app.fetch, port: 3001 }, (info) => {
console.log(`Server running on http://localhost:${info.port}`);
});