This is an open source implementation of OpenCat for Team backend for edge platforms.
Supported platforms:
- Cloudflare Workers
- Deno
- Deno Deploy (requires kv beta access)
This project uses Cloudflare KV or Deno KV as backend database.
Before you begin, you need to have a Cloudflare account and be able to use Cloudflare Workers. Have a joy!
1. Git clone the repo and enter repo
cd ./opencatd_worker
2. Install dependencies
pnpm install
3. Enable Tokens Count Service
cd ./gpt_tokens && cp wrangler.toml.bak wrangler.toml && pnpm run deploy
4. Go into "./opencatd", Copy wrangler.toml.bak
to wrangler.toml
cd ../opencatd && cp wrangler.toml.bak wrangler.toml
5. Create Cloudflare KV Namespace
npx wrangler kv:namespace create OPENCAT_DB
6. Then, copy the created Cloudflare KV config into wrangler.toml, replace 'xxxx...' into your created Cloudflare KV ID.
[[kv_namespaces]]
binding = "OPENCAT_DB"
id = "xxxxx"
7. Custom domain, edit the route configuration in wrangler.toml, rename "xxxxxx..." into your custom domain
[[routes]]
pattern = "xxxxx"
custom_domain = true
8. Use wrangler deploy
pnpm run deploy
You need to have Deno >= 1.32 installed.
1. Install Deno
MacOS user can use under command line to install deno. Read the official document to learn more
brew install deno
2. Copy .env.bak to .env
cp .env.bak .env
3. Run with Deno
Just do it, Deno includes a kv database on the local environment, deno kv database likes a localStorage, you can simple use it. learning more, you can see the comments.
cd ./opencatd && deno run -A --unstable src/server-deno.ts
You need to sign up Deno deploy
You need to have Deno >= 1.32 installed.
Learning how to use Deployctl
1. Install Deno
MacOS user can use under command line to install deno. Read the official document to learn more
brew install deno
2. Install deployctl
deno install --allow-read --allow-write --allow-env --allow-net --allow-run --no-check -r -f https://deno.land/x/deploy/deployctl.ts
3. Deploy
cd ./opencatd && deployctl deploy --project=opencat_worker src/server-deno.ts
This project is MIT licensed.