mirror of
https://github.com/LLM-Red-Team/kimi-free-api.git
synced 2024-12-22 21:29:20 +08:00
支持vercel部署
This commit is contained in:
parent
674647e108
commit
d1e0fcad2b
@ -28,6 +28,7 @@ ZhipuAI (智谱清言) 接口转API [glm-free-api](https://github.com/LLM-Red-Te
|
|||||||
* [多账号接入](#多账号接入)
|
* [多账号接入](#多账号接入)
|
||||||
* [Docker部署](#Docker部署)
|
* [Docker部署](#Docker部署)
|
||||||
* [Docker-compose部署](#Docker-compose部署)
|
* [Docker-compose部署](#Docker-compose部署)
|
||||||
|
* [Vercel部署](#Vercel部署)
|
||||||
* [原生部署](#原生部署)
|
* [原生部署](#原生部署)
|
||||||
* [接口列表](#接口列表)
|
* [接口列表](#接口列表)
|
||||||
* [对话补全](#对话补全)
|
* [对话补全](#对话补全)
|
||||||
@ -143,6 +144,14 @@ services:
|
|||||||
- TZ=Asia/Shanghai
|
- TZ=Asia/Shanghai
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Vercel部署
|
||||||
|
|
||||||
|
**注意:Vercel免费账户的请求响应超时时间为10秒,但接口响应通常较久,可能会遇到Vercel返回的504超时错误**
|
||||||
|
|
||||||
|
点击按钮快速部署:
|
||||||
|
|
||||||
|
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/import/project?template=https://github.com/LLM-Red-Team/kimi-free-api)
|
||||||
|
|
||||||
## 原生部署
|
## 原生部署
|
||||||
|
|
||||||
请准备一台具有公网IP的服务器并将8000端口开放。
|
请准备一台具有公网IP的服务器并将8000端口开放。
|
||||||
|
@ -9,13 +9,15 @@ import { format as dateFormat } from 'date-fns';
|
|||||||
import config from './config.ts';
|
import config from './config.ts';
|
||||||
import util from './util.ts';
|
import util from './util.ts';
|
||||||
|
|
||||||
|
const isVercelEnv = process.env.VERCEL;
|
||||||
|
|
||||||
class LogWriter {
|
class LogWriter {
|
||||||
|
|
||||||
#buffers = [];
|
#buffers = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
fs.ensureDirSync(config.system.logDirPath);
|
!isVercelEnv && fs.ensureDirSync(config.system.logDirPath);
|
||||||
this.work();
|
!isVercelEnv && this.work();
|
||||||
}
|
}
|
||||||
|
|
||||||
push(content) {
|
push(content) {
|
||||||
@ -24,16 +26,16 @@ class LogWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeSync(buffer) {
|
writeSync(buffer) {
|
||||||
fs.appendFileSync(path.join(config.system.logDirPath, `/${util.getDateString()}.log`), buffer);
|
!isVercelEnv && fs.appendFileSync(path.join(config.system.logDirPath, `/${util.getDateString()}.log`), buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
async write(buffer) {
|
async write(buffer) {
|
||||||
await fs.appendFile(path.join(config.system.logDirPath, `/${util.getDateString()}.log`), buffer);
|
!isVercelEnv && await fs.appendFile(path.join(config.system.logDirPath, `/${util.getDateString()}.log`), buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
flush() {
|
flush() {
|
||||||
if(!this.#buffers.length) return;
|
if(!this.#buffers.length) return;
|
||||||
fs.appendFileSync(path.join(config.system.logDirPath, `/${util.getDateString()}.log`), Buffer.concat(this.#buffers));
|
!isVercelEnv && fs.appendFileSync(path.join(config.system.logDirPath, `/${util.getDateString()}.log`), Buffer.concat(this.#buffers));
|
||||||
}
|
}
|
||||||
|
|
||||||
work() {
|
work() {
|
||||||
|
27
vercel.json
Normal file
27
vercel.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"builds": [
|
||||||
|
{
|
||||||
|
"src": "./dist/*.html",
|
||||||
|
"use": "@vercel/static"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "./dist/index.js",
|
||||||
|
"use": "@vercel/node"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"src": "/",
|
||||||
|
"dest": "/dist/welcome.html"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/(.*)",
|
||||||
|
"dest": "/dist",
|
||||||
|
"headers": {
|
||||||
|
"Access-Control-Allow-Credentials": "true",
|
||||||
|
"Access-Control-Allow-Methods": "GET,OPTIONS,PATCH,DELETE,POST,PUT",
|
||||||
|
"Access-Control-Allow-Headers": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, Content-Type, Authorization"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user