feat: 新增限流功能 (#718)
* 请求速率限制 * perf: 优化代码 --------- Co-authored-by: ChenZhaoYu <790348264@qq.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import express from 'express'
|
||||
import type { ChatContext, ChatMessage } from './chatgpt'
|
||||
import { chatConfig, chatReplyProcess, currentModel } from './chatgpt'
|
||||
import { auth } from './middleware/auth'
|
||||
import { limiter } from './middleware/limiter'
|
||||
import { isNotEmptyString } from './utils/is'
|
||||
|
||||
const app = express()
|
||||
@@ -17,7 +18,7 @@ app.all('*', (_, res, next) => {
|
||||
next()
|
||||
})
|
||||
|
||||
router.post('/chat-process', auth, async (req, res) => {
|
||||
router.post('/chat-process', [auth, limiter], async (req, res) => {
|
||||
res.setHeader('Content-type', 'application/octet-stream')
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user