forked from TBXark/ChatGPT-Telegram-Workers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request TBXark#268 from TBXark/dev
fix: prompt插入位置错误BUG
- Loading branch information
Showing
32 changed files
with
955 additions
and
661 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,42 @@ | ||
import adapter from 'cloudflare-worker-adapter'; | ||
import {SqliteCache} from 'cloudflare-worker-adapter/cache/sqlite.js'; | ||
import worker from 'cloudflare-worker-adapter'; | ||
import {default as worker} from '../../main.js'; | ||
import fs from 'fs'; | ||
|
||
const cache = new SqliteCache('./config/cache.sqlite'); | ||
|
||
const config = JSON.parse(fs.readFileSync('./config/config.json', 'utf-8')); | ||
|
||
// 配置数据库 | ||
let cache; | ||
switch (config?.database?.type) { | ||
case 'local': | ||
// eslint-disable-next-line no-case-declarations | ||
const {LocalCache} = await import('cloudflare-worker-adapter/cache/local.js'); | ||
cache = new LocalCache(config.database.uri); | ||
break; | ||
case 'sqlite': | ||
// eslint-disable-next-line no-case-declarations | ||
const {SqliteCache} = await import('cloudflare-worker-adapter/cache/sqlite.js'); | ||
cache = new SqliteCache(config.database.uri); | ||
break; | ||
case 'redis': | ||
// eslint-disable-next-line no-case-declarations | ||
const {RedisCache} = await import('cloudflare-worker-adapter/cache/redis.js'); | ||
cache = new RedisCache(config.database.uri); | ||
break; | ||
default: | ||
// eslint-disable-next-line no-case-declarations | ||
const {MemoryCache} = await import('cloudflare-worker-adapter/cache/memory.js'); | ||
cache = new MemoryCache(); | ||
break; | ||
} | ||
|
||
console.log(`database: ${config?.database?.type} is ready`); | ||
|
||
adapter.startServer( | ||
8787, | ||
'localhost', | ||
'127.0.0.1', | ||
'./config/config.toml', | ||
{DATABASE: cache}, | ||
{server: process.env.DOMAIN}, | ||
{server: config.server}, | ||
worker.fetch, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"sha": "8aa40ac", "timestamp": 1721280807} | ||
{"sha": "de66f3b", "timestamp": 1722427564} |
Oops, something went wrong.