
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
timer-server-tcb
Advanced tools
一个为 小程序云开发 设计的定时任务(Timer Trigger)自动路由框架。
属于 js-rpc 生态的一部分。它允许你将所有定时任务统一管理在一个云函数中,根据 TriggerName 自动分发到 api/ 目录下对应的文件执行。
TriggerName) 自动加载对应文件。npm install timer-server-tcb
建议创建一个专门处理定时任务的云函数(例如命名为 timerEntry):
cloudfunctions/
└── timerEntry/
├── api/ <-- 存放任务逻辑
| ├── history_job.js <-- 对应 config.json 里的 TriggerName
| └── clean_job.js <-- 对应 config.json 里的 TriggerName
├── index.js <-- 入口文件
├── config.json <-- 触发器配置文件
└── package.json
index.js)const { create } = require('timer-server-tcb');
// 一行代码启动路由
exports.main = create();
api/history_job.js)文件名必须与 config.json 中的 name 保持一致。
直接导出一个异步函数即可:
// 你可以使用 cloud sdk
const cloud = require('wx-server-sdk');
cloud.init();
const db = cloud.database();
/**
* 任务逻辑
* @param {object} event - 包含 TriggerName, Time 等信息
* @param {object} context - 云函数上下文
*/
module.exports = async function(event, context) {
console.log('开始执行历史数据抓取任务...');
// 1. 执行业务逻辑
const count = await db.collection('history').count();
// 2. 返回结果(会打印在云函数日志中)
return `任务完成,当前历史记录数: ${count.total}`;
};
config.json)在云函数的 config.json 中定义触发器:
{
"permissions": {
"openapi": []
},
"triggers": [
{
"name": "history_job",
"type": "timer",
"config": "0 0 8 * * * *"
},
{
"name": "clean_job",
"type": "timer",
"config": "0 0 2 * * * *"
}
]
}
上传并部署云函数(记得选择“上传所有文件”),系统会根据 Cron 表达式触发,timer-server-tcb 会自动路由。
FAQs
Auto-router for WeChat Cloud Base Timer Triggers. 微信云开发定时任务自动路由工具。
We found that timer-server-tcb demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.