chore: update index.ts 显示状态
This commit is contained in:
@@ -40,8 +40,8 @@ FLUSH PRIVILEGES;
|
|||||||
mysql -u root -p
|
mysql -u root -p
|
||||||
|
|
||||||
-- 执行以下SQL语句
|
-- 执行以下SQL语句
|
||||||
CREATE USER 'shop_mallnew'@'%' IDENTIFIED BY 'shop_mallnew';
|
CREATE USER 'shop_admin'@'%' IDENTIFIED BY 'shop_admin';
|
||||||
GRANT ALL PRIVILEGES ON huawei_shop_mallnew.* TO 'shop_mallnew'@'%';
|
GRANT ALL PRIVILEGES ON shop_mallnew.* TO 'shop_admin'@'%';
|
||||||
FLUSH PRIVILEGES;
|
FLUSH PRIVILEGES;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
19
src/index.ts
19
src/index.ts
@@ -2,11 +2,28 @@
|
|||||||
import { Elysia } from 'elysia';
|
import { Elysia } from 'elysia';
|
||||||
import routes from './routes';
|
import routes from './routes';
|
||||||
import { config } from 'dotenv';
|
import { config } from 'dotenv';
|
||||||
|
import pool from './db';
|
||||||
config();
|
config();
|
||||||
|
|
||||||
|
// 初始化 Elysia 应用
|
||||||
const app = new Elysia()
|
const app = new Elysia()
|
||||||
.use(routes)
|
.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);
|
.listen(process.env.PORT || 8080);
|
||||||
|
|
||||||
console.log(`🦊 Elysia running on http://localhost:${app.server?.port}`);
|
console.log(`🦊 Elysia running on http://localhost:${app.server?.port}`);
|
||||||
Reference in New Issue
Block a user