Skip to content

wrangler.jsonc 文件定义相关配置 ​

jsonc
{
  "name": "sell-notification",
  // 代码入口文件
  "main": "src/index.js",
  // 兼容 nodejs 环境
  "compatibility_flags": ["nodejs_compat"],
  "compatibility_date": "2026-10-30",
  // 关闭生产环境预览
  "workers_dev": false
  // 日志相关
  // "observability": {
  //   "logs": {
  //     "enabled": true,
  //     "invocation_logs": true
  //   }
  // }
}

代码 ​

js
// do something...

export default {
  fetch(request, env, ctx) {
    return new Response('Hello World!');
  },

  // 配置 cron 后,会定时执行这里面的代码
  scheduled(controller, env, ctx) {
    buy()
  }
};

package.json 部署 ​

json
{
  "scripts": {
    "deploy": "wrangler deploy"
  }
}