2026-03-07 14:36:04 +08:00
|
|
|
|
require('dotenv').config();
|
|
|
|
|
|
const express = require('express');
|
|
|
|
|
|
const cors = require('cors');
|
|
|
|
|
|
|
|
|
|
|
|
const app = express();
|
|
|
|
|
|
app.use(cors());
|
|
|
|
|
|
app.use(express.json());
|
|
|
|
|
|
|
|
|
|
|
|
// 路由引入
|
|
|
|
|
|
const notionRoutes = require('./routes/notion');
|
|
|
|
|
|
const feishuRoutes = require('./routes/feishu');
|
2026-03-12 01:12:52 +08:00
|
|
|
|
const feishuBotRoutes = require('./routes/feishu-bot');
|
2026-03-07 14:36:04 +08:00
|
|
|
|
const routerRoutes = require('./routes/router');
|
2026-03-07 16:20:04 +08:00
|
|
|
|
const coldstartRoutes = require('./routes/coldstart');
|
2026-03-08 22:52:26 +08:00
|
|
|
|
const developersRoutes = require('./routes/developers');
|
2026-03-07 16:28:46 +08:00
|
|
|
|
const hliRoutes = require('../src/routes/hli');
|
2026-03-07 14:36:04 +08:00
|
|
|
|
|
|
|
|
|
|
app.use('/notion', notionRoutes);
|
|
|
|
|
|
app.use('/feishu', feishuRoutes);
|
2026-03-12 01:12:52 +08:00
|
|
|
|
app.use('/feishu-bot', feishuBotRoutes);
|
2026-03-07 14:36:04 +08:00
|
|
|
|
app.use('/router', routerRoutes);
|
2026-03-07 16:20:04 +08:00
|
|
|
|
app.use('/api/coldstart', coldstartRoutes);
|
2026-03-08 22:52:26 +08:00
|
|
|
|
app.use('/api/v1/developers', developersRoutes);
|
2026-03-07 16:28:46 +08:00
|
|
|
|
app.use('/hli', hliRoutes);
|
2026-03-07 14:36:04 +08:00
|
|
|
|
|
|
|
|
|
|
app.get('/', (req, res) => {
|
|
|
|
|
|
res.json({
|
|
|
|
|
|
status: 'ok',
|
|
|
|
|
|
message: 'HoloLake 后端服务运行中',
|
|
|
|
|
|
version: '0.2.0',
|
2026-03-12 01:12:52 +08:00
|
|
|
|
routes: ['/notion/test', '/feishu/test', '/feishu-bot/health', '/router/test', '/router/chat', '/api/coldstart', '/api/v1/developers/test', '/hli/test']
|
2026-03-07 14:36:04 +08:00
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const PORT = process.env.PORT || 3000;
|
2026-03-12 01:12:52 +08:00
|
|
|
|
// 飞书 Webhook 处理(旧版兼容入口,新事件请使用 /feishu-bot/event)
|
2026-03-07 14:36:04 +08:00
|
|
|
|
app.post('/webhook/feishu', (req, res) => {
|
|
|
|
|
|
if (req.body.challenge) {
|
|
|
|
|
|
return res.json({ challenge: req.body.challenge });
|
|
|
|
|
|
}
|
|
|
|
|
|
res.json({ message: 'received' });
|
|
|
|
|
|
});
|
|
|
|
|
|
app.listen(PORT, () => {
|
|
|
|
|
|
console.log(`🚀 服务启动成功,端口:${PORT}`);
|
|
|
|
|
|
});
|