| 123456789101112131415161718192021222324252627282930 |
- import express, { type Express } from 'express';
- import cors from 'cors';
- import qiweiRoutes from './routes/qiwei.routes.js';
- import healthRoutes from './routes/health.routes.js';
- import aggregateRoutes from './routes/aggregate.routes.js';
- import usersRoutes from './routes/users.routes.js';
- import { errorHandler } from './http/error-handler.js';
- import { notFoundHandler } from './http/not-found.middleware.js';
- const app: Express = express();
- app.use(cors());
- app.use(express.json());
- // 企微 API 操作(Webhook / 同步 / 群操作 / 发消息 / 账号测试)
- app.use('/api/qiwe', qiweiRoutes);
- // 聚合计数(替代前端 N+1 count 查询)
- app.use('/api/aggregate', aggregateRoutes);
- // 用户管理(_User 表操作,需 masterKey)
- app.use('/api/users', usersRoutes);
- // 健康检查
- app.use('/api', healthRoutes);
- app.use(notFoundHandler);
- app.use(errorHandler);
- export default app;
|