Update index.js
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
|
||||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
import { checkConnection, query } from './db.js';
|
||||
import { checkConnection, query, initDb } from './db.js';
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
@@ -41,7 +40,15 @@ app.get('/api/tickets', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
// Avvio del server
|
||||
const startServer = async () => {
|
||||
// Attendi inizializzazione DB (creazione tabelle se necessario)
|
||||
await initDb();
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`🚀 Backend Server running on port ${PORT}`);
|
||||
checkConnection(); // Initial check
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
startServer();
|
||||
|
||||
Reference in New Issue
Block a user