- 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
39 lines
No EOL
865 B
TypeScript
39 lines
No EOL
865 B
TypeScript
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(); |