Skip to content

Commit

Permalink
add env: port
Browse files Browse the repository at this point in the history
  • Loading branch information
leafmoes committed Nov 6, 2024
1 parent 9332c45 commit 53e1129
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# API 服务使用的端口
PORT = 8787
# API 调用的前缀地址
API_PREFIX = '/'
# 作为调用 API 验证的 API Key
Expand Down
5 changes: 3 additions & 2 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dotenv.config()

class Config {
constructor() {
this.PORT = process.env.PORT || '/'
this.API_PREFIX = process.env.API_PREFIX || '/'
this.API_KEY = process.env.API_KEY || ''
this.MAX_RETRY_COUNT = process.env.MAX_RETRY_COUNT || 3
Expand Down Expand Up @@ -319,9 +320,9 @@ function newChatCompletionWithModel(text, model) {
if (typeof addEventListener === 'function') return
// For Nodejs
const ittyServer = createServerAdapter(router.fetch)
console.log(`Listening on http://localhost:${process.env.PORT || 8787}`)
console.log(`Listening on http://localhost:${config.PORT || 8787}`)
const httpServer = createServer(ittyServer)
httpServer.listen(8787)
httpServer.listen(config.PORT || 8787)
})()

// export default router
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ docker stop ddg-chat # 停止服务
## 环境变量

```bash
# API 服务使用的端口
PORT = 8787
# API 调用的前缀地址
API_PREFIX = '/'
# 作为调用 API 验证的 API Key
Expand Down

0 comments on commit 53e1129

Please sign in to comment.