Code Monkey home page Code Monkey logo

fadian-cf's Introduction

Cloudflare Worker 反代爱发电 API

使用 Wrangler CLI 开发

安装 wrangler

# npm install -g wrangler
pnpm install -g wrangler
# yarn global add wrangler

登录

# 登录
wrangler login
# 查看登录状态
wrangler whoami
# 登出
wrangler logout

· 远程 VPS 中登录

执行登录命令并在浏览器中授权后,会跳转到一个localhost链接,复制该链接然后新开一个终端窗口,执行以下命令以完成登录;

curl <LOCALHOST_URL>

文档链接:「Using wrangler login on a remote machine

初始配置

克隆项目并安装依赖

git clone [email protected]:wdssmq/fadian-cf.git fadian-cf
cd fadian-cf
pnpm install

设置 Secrets 变量

开发者 | 爱发电:https://afdian.net/dashboard/dev

↑ 点击链接,获取爱发电 ID 和 TOKEN

1、本地开发环境设置 Secrets

  • 在项目根目录下创建 .dev.vars 文件,内容如下:
USER_ID=爱发电 ID
USER_TOKEN=爱发电 TOKEN

2、线上环境设置 Secrets

# 依次执行以下命令,输入对应的值;
wrangler secret put USER_ID

wrangler secret put USER_TOKEN

# 查看 Secrets
wrangler secret list

# 删除 Secrets
# wrangler secret delete <KEY> [OPTIONS]

运行 / 发布

执行命令后可以按 [b] 键打开浏览器,[d] 键打开开发者工具,[l] 键开启本地模式,[c] 键清空控制台,[x] 键退出;

默认可能会超时报错,所以建议切换本地模式;

✘ [ERROR] Error while creating remote dev session: TypeError: fetch failed

# 调试运行
npm start

# │ [b] open a browser, [d] open Devtools, [l] turn on local mode, [c] clear console, [x] to exit
# 发布
npm run deploy

参考文档

Environment variables · Cloudflare Workers docs https://developers.cloudflare.com/workers/platform/environment-variables/#add-secrets-to-your-project

Commands · Cloudflare Workers docs https://developers.cloudflare.com/workers/wrangler/commands/#secret

投喂

二维码:https://github.com/wdssmq#二维码

爱发电:https://afdian.net/a/wdssmq

更多「小代码」:https://cn.bing.com/search?q=小代码+沉冰浮水

fadian-cf's People

Contributors

wdssmq avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.