feat: 更新服务器端口为7328,调整相关文档和示例

This commit is contained in:
dzq 2025-12-12 10:59:51 +08:00
parent 7be8cc973e
commit bddd42a6c0
4 changed files with 14 additions and 14 deletions

View File

@ -17,7 +17,7 @@ pnpm build # 构建项目用于部署
### Express API 服务器 ### Express API 服务器
```bash ```bash
pnpm server:dev # 启动Express开发服务器http://localhost:3000 pnpm server:dev # 启动Express开发服务器http://localhost:7328
pnpm server:start # 启动Express生产服务器 pnpm server:start # 启动Express生产服务器
``` ```
@ -84,10 +84,10 @@ cp .env.example .env
pnpm server:dev pnpm server:dev
``` ```
启动后可通过以下方式访问: 启动后可通过以下方式访问:
- **健康检查**: http://localhost:3000/health - **健康检查**: http://localhost:7328/health
- **Agent API**: http://localhost:3000/api/agent - **Agent API**: http://localhost:7328/api/agent
- **生成响应**: POST http://localhost:3000/api/agent/generate - **生成响应**: POST http://localhost:7328/api/agent/generate
- **流式响应**: POST http://localhost:3000/api/agent/stream - **流式响应**: POST http://localhost:7328/api/agent/stream
### 4. 扩展项目 ### 4. 扩展项目

View File

@ -42,12 +42,12 @@ pnpm server:start
### 获取 Agent 信息 ### 获取 Agent 信息
```bash ```bash
curl http://localhost:3000/api/agent curl http://localhost:7328/api/agent
``` ```
### 生成响应 ### 生成响应
```bash ```bash
curl -X POST http://localhost:3000/api/agent/generate \ curl -X POST http://localhost:7328/api/agent/generate \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{ -d '{
"message": "What is the weather in Beijing?", "message": "What is the weather in Beijing?",
@ -59,7 +59,7 @@ curl -X POST http://localhost:3000/api/agent/generate \
### 流式响应 ### 流式响应
```bash ```bash
curl -X POST http://localhost:3000/api/agent/stream \ curl -X POST http://localhost:7328/api/agent/stream \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{ -d '{
"message": "Tell me a joke" "message": "Tell me a joke"
@ -68,7 +68,7 @@ curl -X POST http://localhost:3000/api/agent/stream \
### 测试所有工具 ### 测试所有工具
```bash ```bash
curl -X POST http://localhost:3000/api/agent/test-tools curl -X POST http://localhost:7328/api/agent/test-tools
``` ```
## 响应格式 ## 响应格式
@ -111,7 +111,7 @@ Agent 包含以下工具:
## 环境变量 ## 环境变量
- `PORT` - 服务器端口 (默认: 3000) - `PORT` - 服务器端口 (默认: 7328)
- `NODE_ENV` - 环境模式 (development/production) - `NODE_ENV` - 环境模式 (development/production)
- `CORS_ORIGIN` - CORS 允许的源 (默认: '*') - `CORS_ORIGIN` - CORS 允许的源 (默认: '*')
@ -135,7 +135,7 @@ src/server/
1. 确保已安装所有依赖:`pnpm install` 1. 确保已安装所有依赖:`pnpm install`
2. 开发模式运行:`pnpm server:dev` 2. 开发模式运行:`pnpm server:dev`
3. 访问 `http://localhost:3000/health` 确认服务运行正常 3. 访问 `http://localhost:7328/health` 确认服务运行正常
4. 使用 API 客户端测试各端点功能 4. 使用 API 客户端测试各端点功能
## 注意事项 ## 注意事项
@ -143,4 +143,4 @@ src/server/
- 天气工具需要网络连接访问外部 API - 天气工具需要网络连接访问外部 API
- 流式响应使用 Server-Sent Events (SSE) - 流式响应使用 Server-Sent Events (SSE)
- 生产环境建议配置合适的 CORS 策略 - 生产环境建议配置合适的 CORS 策略
- 默认端口为 3000,可通过环境变量修改 - 默认端口为 7328,可通过环境变量修改

View File

@ -8,7 +8,7 @@ import { responseFormatter } from './middleware/response-formatter';
import { errorHandler, notFoundHandler } from './middleware/error-handler'; import { errorHandler, notFoundHandler } from './middleware/error-handler';
const app = express(); const app = express();
const PORT = process.env.PORT || 3000; const PORT = process.env.PORT || 7328;
// Security middleware // Security middleware
app.use(helmet()); app.use(helmet());

View File

@ -4,7 +4,7 @@ import { VitePluginNode } from 'vite-plugin-node';
export default defineConfig({ export default defineConfig({
root: '.', // 设置根目录 root: '.', // 设置根目录
server: { server: {
port: 3000, port: 7328,
}, },
build: { build: {
outDir: 'dist', outDir: 'dist',