-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
30 lines (24 loc) · 918 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const express = require('express');
const bodyParser = require('body-parser');
const { sequelize } = require('./config/database');
const healthRoutes = require('./routes/healthRoutes');
const userRoutes = require('./routes/userRoutes');
const serverRoutes = require('./routes/serverRoutes');
const instanceRoutes = require('./routes/instanceRoutes');
const app = express();
const port = process.env.PORT || 5000;
app.use(bodyParser.json());
app.use('/health', healthRoutes);
app.use('/users', userRoutes);
app.use('/servers', serverRoutes);
app.use('/instances', instanceRoutes);
// Test database connection and sync models
sequelize.sync().then(() => {
console.log('Database connected and models synced');
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
}).catch(err => {
console.error('Unable to connect to the database:', err);
});
module.exports = app;