Skip to content

基于 push-all-in-one 和 hono 开发的云函数推送服务。支持 nodejs/docker/vercel 等多种部署方式

License

Notifications You must be signed in to change notification settings

CaoMeiYouRen/push-all-in-cloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

push-all-in-cloud

Version Docker Pulls GitHub Workflow Status Documentation Maintenance License: AGPL-3.0

基于 push-all-in-one 和 hono 开发的云函数推送服务。支持 nodejs/docker/vercel 等部署方式

🏠 主页

https://github.com/CaoMeiYouRen/push-all-in-cloud#readme

📦 依赖要求

  • node >=18
  • pnpm >= 9

🚀 部署

Vercel 部署(推荐)

点击以下按钮一键部署到 Vercel。

Deploy with Vercel

Docker 镜像

支持两种注册表:

支持以下架构:

  • linux/amd64
  • linux/arm64

有以下几种 tags:

Tag 描述 举例
latest 最新 latest
{YYYY-MM-DD} 特定日期 2024-06-07
{sha-hash} 特定提交 sha-0891338
{version} 特定版本 1.2.3

Docker Compose 部署

下载 docker-compose.yml

wget https://raw.githubusercontent.com/CaoMeiYouRen/push-all-in-cloud/refs/heads/master/docker-compose.yml

检查有无需要修改的配置

vim docker-compose.yml  # 也可以是你喜欢的编辑器

在公网部署时请务必修改 AUTH_PUSH_KEY、AUTH_FORWARD_KEY 环境变量

启动

docker-compose up -d

在浏览器中打开 http://{Server IP}:3000 即可查看结果

Node.js 部署

确保本地已安装 Node.js 和 pnpm。

# 下载源码
git clone https://github.com/CaoMeiYouRen/push-all-in-cloud.git  --depth=1
cd push-all-in-cloud
# 安装依赖
pnpm i --frozen-lockfile
# 构建项目
pnpm build
# 启动项目
pnpm start

在浏览器中打开 http://{Server IP}:3000 即可查看结果

👨‍💻 使用

如果在本地部署,基础路径为 http://localhost:3000

在服务器或云函数部署则为 http(s)://{Server IP}

例如:

如果基础路径为 https://example.vercel.app,则 /push 的完整路径为 https://example.vercel.app/push

接口说明

路径 请求方法 请求格式 请求内容 响应内容 说明
/push POST application/json PushBody PushResponse 将消息推送到服务端配置的多个推送渠道。使用本方式需要配置环境变量
/forward POST application/json ForwardBody ForwardResponse 将消息转发到目标推送渠道。使用本方式无需配置环境变量,但需要在推送时设置推送渠道
type PushBody = {
    title: string
    desp?: string
}

type PushType = "ServerChanTurbo" | "Dingtalk" | "CustomEmail" | "WechatRobot" | "WechatApp" | "PushPlus" | "IGot" | "Qmsg" | "XiZhi" | "PushDeer" | "Discord" | "Telegram" | "OneBot"

type ForwardBody = {
    title: string
    desp?: string
    type: PushType
    // config 相关配置请参考下文的环境变量配置
    config: Record<string, string>
}

type PushResponse = {
    message: string
    data: PromiseSettledResult<Pick<AxiosResponse<any>, 'data' | 'headers' | 'status' | 'statusText'>>[]
}

type ForwardResponse = {
    message: string
    data: Pick<AxiosResponse<any>, 'data' | 'headers' | 'status' | 'statusText'>
}

/push 接口调用例子

// 注意:/push 接口需要先配置环境变量!!!
const url = 'http://your-server-address/push'; // 请将 http://your-server-address 替换为真实地址!
const authToken = 'your-auth-push-key'; // 请将 your-auth-push-key 替换为真实 AUTH_PUSH_KEY

const payload = {
    title: '测试推送标题',
    desp: '这是测试推送的内容'
};

fetch(url, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${authToken}`
    },
    body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

/forward 接口调用例子

const url = 'http://your-server-address/forward'; // 请将 http://your-server-address 替换为真实地址!
const authToken = 'your-auth-forward-key'; // 请将 your-auth-forward-key 替换为真实 AUTH_FORWARD_KEY

const payload = {
    title: '测试推送标题',
    desp: '这是测试推送的内容',
    type: 'Telegram', // 选择推送渠道,例如 Telegram
    config: {
        TELEGRAM_BOT_TOKEN: 'your-telegram-bot-token',
        TELEGRAM_CHAT_ID: 'your-telegram-chat-id'
    }
};

fetch(url, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${authToken}`
    },
    body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

环境变量配置

环境变量 说明
PORT 运行端口
AUTH_PUSH_KEY 【建议设置】访问 /push 路由,执行推送请求需要的 key。验证方式为 Bearer Auth。由于该路由需要在环境变量配置推送渠道,所以不设置该项将有接口被盗刷的风险。
AUTH_FORWARD_KEY 访问 /forward 路由,执行转发推送需要的 key。验证方式为 Bearer Auth
SCTKEY Server 酱·Turbo SCTKEY。官方文档:https://sct.ftqq.com/
SERVER_CHAN_V3_KEY Server 酱³ 的 sendkey。官方文档:https://sc3.ft07.com/doc
EMAIL_AUTH_USER 自定义邮箱。发件邮箱
EMAIL_AUTH_PASS 发件授权码(或密码)
EMAIL_HOST 发件域名
EMAIL_PORT 发件端口
EMAIL_TO_ADDRESS 收件邮箱
DINGTALK_ACCESS_TOKEN 【推荐】钉钉机器人 access_token。官方文档:https://developers.dingtalk.com/document/app/custom-robot-access
DINGTALK_SECRET 钉钉机器人加签安全秘钥(HmacSHA256)
WX_ROBOT_KEY 企业微信群机器人。官方文档:https://work.weixin.qq.com/help?person_id=1&doc_id=13376
WX_ROBOT_MSG_TYPE 消息类型,默认 text
WX_APP_CORPID 【推荐】企业微信企业 ID,获取方式参考 https://work.weixin.qq.com/api/doc/90000/90135/91039#14953/corpid
WX_APP_AGENTID 企业应用的 id。企业内部开发,可在应用的设置页面查看
WX_APP_SECRET 应用的凭证密钥,获取方式参考:https://work.weixin.qq.com/api/doc/90000/90135/91039#14953/secret
WX_APP_USERID 指定接收消息的成员。若不指定则默认为 ”@all”。
PUSH_PLUS_TOKEN pushplus 推送加开放平台。官方文档:http://pushplus.hxtrip.com/doc/
PUSH_PLUS_TEMPLATE_TYPE 发送消息模板,默认为 html
PUSH_PLUS_CHANNEL_TYPE 发送渠道,默认为 wechat
I_GOT_KEY iGot 推送,官方文档:https://wahao.github.io/Bark-MP-helper
QMSG_KEY Qmsg 酱 推送,官方文档:https://qmsg.zendee.cn
XI_ZHI_KEY 息知 推送,官方文档:https://xz.qqoq.net/#/index
PUSH_DEER_PUSH_KEY 【推荐】PushDeer 推送,官方文档:https://github.com/easychen/pushdeer
DISCORD_WEBHOOK 【推荐】Discord Webhook Url 可在服务器设置 -> 整合 -> Webhook -> 创建 Webhook 中获取。官方文档:https://support.discord.com/hc/zh-tw/articles/228383668-%E4%BD%BF%E7%94%A8%E7%B6%B2%E7%B5%A1%E9%89%A4%E6%89%8B-Webhooks-
DISCORD_USERNAME 机器人显示的名称
TELEGRAM_BOT_TOKEN 【推荐】Telegram Bot 机器人令牌。您可以从 https://t.me/BotFather 获取 Token。官方文档:https://core.telegram.org/bots/api#making-requests
TELEGRAM_CHAT_ID 支持对话/群组/频道的 Chat ID。您可以转发消息到 https://t.me/JsonDumpBot 获取 Chat ID
ONE_BOT_BASE_URL OneBot 推送。OneBot HTTP 基础路径。官方文档:https://github.com/botuniverse/onebot-11
ONE_BOT_ACCESS_TOKEN OneBot AccessToken
ONE_BOT_MSG_TYPE 消息类型
ONE_BOT_RECIEVER_ID 用户/群组 ID,即 QQ 号或群号

🛠️ 开发

npm run dev

🔧 编译

npm run build

🔍 Lint

npm run lint

👤 作者

CaoMeiYouRen

🤝 贡献

欢迎 贡献、提问或提出新功能!
如有问题请查看 issues page.
贡献或提出新功能可以查看contributing guide.

💰 支持

如果觉得这个项目有用的话请给一颗⭐️,非常感谢

🌟 Star History

Star History Chart

📝 License

Copyright © 2024 CaoMeiYouRen.
This project is AGPL-3.0 licensed.


This README was generated with ❤️ by cmyr-template-cli