feat: Add Swagger documentation support and restructure routes

- Added @elysiajs/swagger dependency to package.json for API documentation.
- Removed the old bed router and replaced it with a new history router.
- Created a new state router to manage WebSocket connections and state updates.
- Implemented a comprehensive state management system with the StateManager service.
- Introduced AlarmManagement and BedService services for handling alarms and sensor readings.
- Established a new MQTT service for managing MQTT connections and subscriptions.
- Created an AlarmStateStore to manage volatile alerts and their states.
- Defined FrontendState types for structured state management and WebSocket messaging.
This commit is contained in:
Siwat Sirichai 2025-06-21 18:56:34 +07:00
parent a767dc3635
commit 4ae5196ef1
12 changed files with 1189 additions and 1 deletions

7
app.ts
View file

@ -3,6 +3,8 @@ import { cors } from '@elysiajs/cors';
import { createTopicLogger } from '~/utils/logger';
import env from './config/env';
import stateRouter from './routes/state';
import swaggerElysia from './routes/swagger';
async function initialize() {
const logger = createTopicLogger({ topic: 'Initializer' });
@ -12,7 +14,6 @@ async function initialize() {
logger.error(`Initialization error: ${error}`);
process.exit(1);
}
}
async function initializeElysia() {
@ -31,6 +32,10 @@ async function initializeElysia() {
// Core Components
.use(cors())
.use(swaggerElysia)
// State routes (includes WebSocket)
.use(stateRouter)
// Start the server
app.listen(PORT);