feat: restructure backend with Elysia framework and add MQTT adapter
- Updated .gitignore to exclude generated files and database - Modified package.json to change dev script and add new dependencies - Removed src/index.ts and created app.ts for Elysia server initialization - Added environment variable configuration in config/env.ts - Implemented MQTT adapter in adapter/mqtt.ts for message handling - Created Prisma client in prisma/client.ts and defined schema in prisma/schema.prisma - Added seeding script in prisma/seed.ts for measurement points - Established logging utility in utils/logger.ts for structured logging - Created bed router in routes/bed.ts for handling bed-related routes
This commit is contained in:
parent
b76d6b99ee
commit
a767dc3635
14 changed files with 801 additions and 14 deletions
39
app.ts
Normal file
39
app.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { Elysia } from 'elysia';
|
||||
import { cors } from '@elysiajs/cors';
|
||||
|
||||
import { createTopicLogger } from '~/utils/logger';
|
||||
import env from './config/env';
|
||||
|
||||
async function initialize() {
|
||||
const logger = createTopicLogger({ topic: 'Initializer' });
|
||||
try {
|
||||
await initializeElysia();
|
||||
} catch (error) {
|
||||
logger.error(`Initialization error: ${error}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function initializeElysia() {
|
||||
const logger = createTopicLogger({ topic: 'Elysia' });
|
||||
const PORT = env.BACKEND_PORT;
|
||||
|
||||
// Instantiate and configure Elysia
|
||||
const app = new Elysia()
|
||||
// Logging Messages
|
||||
.onStart(() => {
|
||||
logger.info(`API server starting on port ${PORT}`);
|
||||
})
|
||||
.onStop(() => {
|
||||
logger.info('API server shutting down');
|
||||
})
|
||||
|
||||
// Core Components
|
||||
.use(cors())
|
||||
|
||||
// Start the server
|
||||
app.listen(PORT);
|
||||
}
|
||||
|
||||
initialize();
|
Loading…
Add table
Add a link
Reference in a new issue