forked from sho810339/software
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (24 loc) · 901 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 signinRoutes = require('./routes/signinRoutes');
const captainRoutes = require('./routes/captainRoutes');
const workerRoutes = require('./routes/workerRoutes');
const alertRoutes = require('./routes/alertRoutes');
const sequelize = require('./config/database'); // 資料庫連線
const app = express();
// 中間件
app.use(bodyParser.json());
// 路由設定
app.use('/api/signin', signinRoutes);
app.use('/api/captain', captainRoutes);
app.use('/api/workers', workerRoutes);
app.use('/api/alerts', alertRoutes);
// 測試資料庫連線
sequelize.authenticate()
.then(() => console.log('資料庫連線成功'))
.catch(err => console.error('資料庫連線失敗:', err));
// 啟動伺服器
const PORT = 3000;
app.listen(PORT, () => {
console.log(`伺服器正在執行,監聽 port ${PORT}`);
});