feat: 更新服务器端口为7328,调整相关文档和示例
This commit is contained in:
parent
7be8cc973e
commit
bddd42a6c0
10
CLAUDE.md
10
CLAUDE.md
|
|
@ -17,7 +17,7 @@ pnpm build # 构建项目用于部署
|
|||
|
||||
### Express API 服务器
|
||||
```bash
|
||||
pnpm server:dev # 启动Express开发服务器(http://localhost:3000)
|
||||
pnpm server:dev # 启动Express开发服务器(http://localhost:7328)
|
||||
pnpm server:start # 启动Express生产服务器
|
||||
```
|
||||
|
||||
|
|
@ -84,10 +84,10 @@ cp .env.example .env
|
|||
pnpm server:dev
|
||||
```
|
||||
启动后可通过以下方式访问:
|
||||
- **健康检查**: http://localhost:3000/health
|
||||
- **Agent API**: http://localhost:3000/api/agent
|
||||
- **生成响应**: POST http://localhost:3000/api/agent/generate
|
||||
- **流式响应**: POST http://localhost:3000/api/agent/stream
|
||||
- **健康检查**: http://localhost:7328/health
|
||||
- **Agent API**: http://localhost:7328/api/agent
|
||||
- **生成响应**: POST http://localhost:7328/api/agent/generate
|
||||
- **流式响应**: POST http://localhost:7328/api/agent/stream
|
||||
|
||||
### 4. 扩展项目
|
||||
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ pnpm server:start
|
|||
|
||||
### 获取 Agent 信息
|
||||
```bash
|
||||
curl http://localhost:3000/api/agent
|
||||
curl http://localhost:7328/api/agent
|
||||
```
|
||||
|
||||
### 生成响应
|
||||
```bash
|
||||
curl -X POST http://localhost:3000/api/agent/generate \
|
||||
curl -X POST http://localhost:7328/api/agent/generate \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"message": "What is the weather in Beijing?",
|
||||
|
|
@ -59,7 +59,7 @@ curl -X POST http://localhost:3000/api/agent/generate \
|
|||
|
||||
### 流式响应
|
||||
```bash
|
||||
curl -X POST http://localhost:3000/api/agent/stream \
|
||||
curl -X POST http://localhost:7328/api/agent/stream \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"message": "Tell me a joke"
|
||||
|
|
@ -68,7 +68,7 @@ curl -X POST http://localhost:3000/api/agent/stream \
|
|||
|
||||
### 测试所有工具
|
||||
```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)
|
||||
- `CORS_ORIGIN` - CORS 允许的源 (默认: '*')
|
||||
|
||||
|
|
@ -135,7 +135,7 @@ src/server/
|
|||
|
||||
1. 确保已安装所有依赖:`pnpm install`
|
||||
2. 开发模式运行:`pnpm server:dev`
|
||||
3. 访问 `http://localhost:3000/health` 确认服务运行正常
|
||||
3. 访问 `http://localhost:7328/health` 确认服务运行正常
|
||||
4. 使用 API 客户端测试各端点功能
|
||||
|
||||
## 注意事项
|
||||
|
|
@ -143,4 +143,4 @@ src/server/
|
|||
- 天气工具需要网络连接访问外部 API
|
||||
- 流式响应使用 Server-Sent Events (SSE)
|
||||
- 生产环境建议配置合适的 CORS 策略
|
||||
- 默认端口为 3000,可通过环境变量修改
|
||||
- 默认端口为 7328,可通过环境变量修改
|
||||
|
|
@ -8,7 +8,7 @@ import { responseFormatter } from './middleware/response-formatter';
|
|||
import { errorHandler, notFoundHandler } from './middleware/error-handler';
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
const PORT = process.env.PORT || 7328;
|
||||
|
||||
// Security middleware
|
||||
app.use(helmet());
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { VitePluginNode } from 'vite-plugin-node';
|
|||
export default defineConfig({
|
||||
root: '.', // 设置根目录
|
||||
server: {
|
||||
port: 3000,
|
||||
port: 7328,
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
|
|
|
|||
Loading…
Reference in New Issue