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

Repository files navigation

This repository is archived and no longer maintained. All features have been migrated to separate repositories.

Introduction

My personal Cloudflare WorkersAPI repository

Usage

Configure Environment Variables

Please Fork this repository, manually create the wrangler.toml file, and add the following content:

name = "api"main = "dist/index.js"compatibility_date = "2024-04-05"assets = { directory = "public" }
[vars]
KEY = "VALUE"# See Environment Variables# Only used for counting visits, can be omitted
[[d1_databases]]
binding = "count"database_name = "YOUR_D1_DATABASE_NAME"database_id = "YOUR_D1_DATABASE_ID"# Only used for FileBox, can be omitted
[[r2_buckets]]
binding = "filebox"bucket_name = "YOUR_BUCKET_NAME"
[observability] # Optionalenabled = true# Optional

Environment Variables

  • CF_USER: Cloudflare user ID, for PainterLeaf and CyberLeaf
  • CF_AI_API_KEY: Cloudflare AIAPI key, for PainterLeaf and CyberLeaf
  • HF_API_KEY: Hugging FaceAPI key, for PainterLeaf
  • PAINTERLEAF_SERVER_PASSWORD: PainterLeaf server password, for PainterLeaf
  • WEATHER_API_KEY: qWeatherAPI key, for MyHomepage
  • FILEBOX_UPLOAD_PW: FileBox upload password, for FileBox
  • FILEBOX_DOWNLOAD_PW: FileBox download password, for FileBox

If you don't need to use a certain feature, it's okay not to set the corresponding environment variable.

Deployment

# Install dependencies
npm i -g bun # if you haven't installed bun yet
bun i
# Login to Cloudflare
bunx wrangler login
# Deploy
bun dep

API Reference

CategoryFunctionPathMethodQuery ParametersRequest BodyResponse
PainterLeafGet model list/painter/modelsGET--application/json
PainterLeafGenerate image/painter/generatePOST-prompt: prompt words
model: model name
If img2img: image: Array.from(uint8Array)
image/png
PainterLeafTranslate prompt words/painter/translatePOST-text: text
source_lang: source language
target_lang: target language
application/json
MyHomepageqWeather/weatherGETlocation: longitude,latitude-application/json
PainterLeafGenerate text from image/painter/genpromptPOST-image: Array.from(uint8Array)application/json
PainterLeafGenerate text from image
with llama3.2 vision
/painter/genprompt/v4POST-image: Array.from(uint8Array)application/json
OthersCount visits/countGET--text/javascript
OthersCount visits/countPOST-hostname: domain name
unique: whether to count as unique visitors
application/json
FileBoxUpload file/filebox/uploadPOST-key: pickup code
filename: file name
password: upload password
file: base64 encoded file
application/json
FileBoxDownload file/filebox/downloadPOST-key: pickup code
password: download password
shouldDelete: whether to delete the file
filetype: file or text
application/json
OthersReturn my avatar/avatar.jpgGET--image/jpeg
OthersReturn public avatar/public_avatar.pngGET--image/png
CyberLeafChat/being/chatPOST-messages: { role: string, content: string }[]application/json
CyberLeafTest Connection/being/testPOST-msg: 'ping'msg: 'pong'

About

Cloudflare Workers APIs for my projects / 我的各种项目的 Cloudflare Workers 的后端

Topics

Resources

Stars

10 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages