chore: update index.ts 显示状态

This commit is contained in:
2025-11-28 15:00:31 +08:00
parent dce01b2a20
commit 97c0c7c0fc
2 changed files with 20 additions and 3 deletions

View File

@@ -40,8 +40,8 @@ FLUSH PRIVILEGES;
mysql -u root -p
-- 执行以下SQL语句
CREATE USER 'shop_mallnew'@'%' IDENTIFIED BY 'shop_mallnew';
GRANT ALL PRIVILEGES ON huawei_shop_mallnew.* TO 'shop_mallnew'@'%';
CREATE USER 'shop_admin'@'%' IDENTIFIED BY 'shop_admin';
GRANT ALL PRIVILEGES ON shop_mallnew.* TO 'shop_admin'@'%';
FLUSH PRIVILEGES;
```

View File

@@ -2,11 +2,28 @@
import { Elysia } from 'elysia';
import routes from './routes';
import { config } from 'dotenv';
import pool from './db';
config();
// 初始化 Elysia 应用
const app = new Elysia()
.use(routes)
.get('/', () => 'SaaS Admin API - Ready for Dify Agent')
// 根路由,返回 API 就绪状态, 用于健康检查, 显示数据库连接状态
.get('/', async () => {
// 检查数据库连接
let dbConnected: string;
try {
await pool.getConnection();
dbConnected = 'connected';
} catch (err) {
dbConnected = 'disconnected';
}
return {
message: 'SaaS Admin API - Ready for Dify Agent',
status: 'ready',
database: dbConnected,
};
})
.listen(process.env.PORT || 8080);
console.log(`🦊 Elysia running on http://localhost:${app.server?.port}`);