38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
import dotenv from 'dotenv';
|
|
import http from 'http';
|
|
import app from './app.js';
|
|
import { connectDatabase } from './src/shared/database/connection.js';
|
|
import { SocketService } from './src/shared/services/socket.service.js';
|
|
|
|
// Load environment variables
|
|
dotenv.config();
|
|
|
|
const PORT = process.env.PORT || 5000;
|
|
|
|
async function bootstrap() {
|
|
try {
|
|
// Connect database
|
|
await connectDatabase();
|
|
|
|
// Create HTTP Server
|
|
const server = http.createServer(app);
|
|
|
|
// Initialize Socket.io service
|
|
SocketService.init(server);
|
|
|
|
server.listen(PORT, () => {
|
|
console.log(`==================================================`);
|
|
console.log(` Enterprise PIM Backend Server Started `);
|
|
console.log(` Port: ${PORT} `);
|
|
console.log(` Env: ${process.env.NODE_ENV || 'development'} `);
|
|
console.log(` Docs: http://localhost:${PORT}/api/docs `);
|
|
console.log(`==================================================`);
|
|
});
|
|
} catch (error) {
|
|
console.error('Bootstrap error occurred:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
bootstrap();
|