File
Blob: worker/src/server/routes/device.ts
| 1 | import { Hono } from 'hono'; |
| 2 | import { |
| 3 | deviceHeartbeatSchema, |
| 4 | deviceStartSchema, |
| 5 | generationSchema, |
| 6 | } from '@/shared/contracts/signaling.ts'; |
| 7 | import type { HttpApp } from '@/server/http.ts'; |
| 8 | import { input, result, room } from './context.ts'; |
| 9 | |
| 10 | const app = new Hono<HttpApp>(); |
| 11 | app.post('/start', async (c) => |
| 12 | result(c, await room(c).startDevice(await input(c, deviceStartSchema))), |
| 13 | ); |
| 14 | app.post('/channels', async (c) => |
| 15 | result(c, await room(c).createDeviceChannels((await input(c, generationSchema)).generation)), |
| 16 | ); |
| 17 | app.post('/ready', async (c) => |
| 18 | result(c, await room(c).deviceReady((await input(c, generationSchema)).generation)), |
| 19 | ); |
| 20 | app.post('/heartbeat', async (c) => |
| 21 | result(c, await room(c).deviceHeartbeat(await input(c, deviceHeartbeatSchema))), |
| 22 | ); |
| 23 | |
| 24 | export default app; |