Skip to content

Commit a096f41

Browse files
committed
docs: update server.js file
1 parent 740a4a5 commit a096f41

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

email-api/src/server.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import app from './app.js'
1+
/*import app from './app.js'
22
import { connectDB } from './db/connect.js'
33
44
const serverStart = async () => {
@@ -13,4 +13,28 @@ const serverStart = async () => {
1313
}
1414
}
1515
16+
serverStart()*/
17+
18+
import app from './app.js'
19+
// CAMBIO: Importamos el objeto sequelize por defecto (sin llaves)
20+
import sequelize from './db/connect.js'
21+
22+
const serverStart = async () => {
23+
try {
24+
// CAMBIO: Usamos authenticate() para verificar la conexión
25+
await sequelize.authenticate()
26+
console.log('Database connected successfully')
27+
28+
// Opcional: Si quieres que se sincronicen las tablas al arrancar:
29+
// await sequelize.sync()
30+
31+
app.listen(app.get('port'), () => {
32+
console.log(`Server running on port http://localhost:${app.get('port')}`)
33+
})
34+
} catch (error) {
35+
console.error('Error starting server:', error)
36+
process.exit(1)
37+
}
38+
}
39+
1640
serverStart()

0 commit comments

Comments
 (0)