Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit f86735a

Browse files
committed
fix: api exception call not throwing error
1 parent 5fc7169 commit f86735a

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

api/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dotenv.config()
77

88
class Config {
99
constructor() {
10-
this.PORT = process.env.PORT || '/'
10+
this.PORT = process.env.PORT || 8787
1111
this.API_PREFIX = process.env.API_PREFIX || '/'
1212
this.API_KEY = process.env.API_KEY || ''
1313
this.MAX_RETRY_COUNT = process.env.MAX_RETRY_COUNT || 3
@@ -63,7 +63,7 @@ const logger = (res, req) => {
6363

6464
const router = AutoRouter({
6565
before: [withBenchmarking, preflight, withAuth],
66-
missing: () => error(404, '404 not found.'),
66+
missing: () => error(404, '404 Not Found. Please check whether the calling URL is correct.'),
6767
finally: [corsify, logger],
6868
})
6969

@@ -90,7 +90,7 @@ async function handleCompletion(request) {
9090
const content = messagesPrepare(messages)
9191
return createCompletion(model, content, returnStream)
9292
} catch (err) {
93-
error(500, err.message)
93+
return error(500, err.message)
9494
}
9595
}
9696

@@ -320,9 +320,9 @@ function newChatCompletionWithModel(text, model) {
320320
if (typeof addEventListener === 'function') return
321321
// For Nodejs
322322
const ittyServer = createServerAdapter(router.fetch)
323-
console.log(`Listening on http://localhost:${config.PORT || 8787}`)
323+
console.log(`Listening on http://localhost:${config.PORT}`)
324324
const httpServer = createServer(ittyServer)
325-
httpServer.listen(config.PORT || 8787)
325+
httpServer.listen(config.PORT)
326326
})()
327327

328328
// export default router

dist/index.js

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

render.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
plan: free
88
envVars:
99
- key: PORT
10-
value: '8787'
10+
value: 8787
1111
- key: API_PREFIX
1212
value: '/'
1313
- key: API_KEY

0 commit comments

Comments
 (0)