-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathindex.js
More file actions
22 lines (18 loc) · 560 Bytes
/
index.js
File metadata and controls
22 lines (18 loc) · 560 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const { sequelize } = require('./config/sequelize');
// Ensure models are registered before sync
require('./api/models/Url');
const app = require('./config/express');
async function start() {
await sequelize.authenticate();
if (process.env.NODE_ENV === 'development') {
await sequelize.sync();
}
const port = parseInt(process.env.PORT, 10) || 3000;
app.listen(port, () => {
console.log(`The server is running at localhost:${port}`);
});
}
start().catch((err) => {
console.error('Failed to start server:', err);
process.exit(1);
});