{"id":20942089,"url":"https://github.com/salakjs/salak-schedule","last_synced_at":"2025-07-22T12:35:22.881Z","repository":{"id":57356068,"uuid":"133596483","full_name":"SalakJS/salak-schedule","owner":"SalakJS","description":"Timed task for salak.","archived":false,"fork":false,"pushed_at":"2019-06-22T15:05:56.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-23T07:41:35.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SalakJS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-16T02:02:36.000Z","updated_at":"2018-08-23T07:52:50.000Z","dependencies_parsed_at":"2022-09-26T16:32:05.600Z","dependency_job_id":null,"html_url":"https://github.com/SalakJS/salak-schedule","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SalakJS/salak-schedule","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SalakJS%2Fsalak-schedule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SalakJS%2Fsalak-schedule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SalakJS%2Fsalak-schedule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SalakJS%2Fsalak-schedule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SalakJS","download_url":"https://codeload.github.com/SalakJS/salak-schedule/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SalakJS%2Fsalak-schedule/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260350119,"owners_count":22995697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T23:22:36.923Z","updated_at":"2025-06-17T11:37:01.630Z","avatar_url":"https://github.com/SalakJS.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# salak-schedule\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![David deps][david-image]][david-url]\n[![NPM download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/salak-schedule.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/salak-schedule\n[travis-image]: https://img.shields.io/travis/SalakJS/salak-schedule.svg?style=flat-square\n[travis-url]: https://travis-ci.org/SalakJS/salak-schedule\n[david-image]: https://img.shields.io/david/SalakJS/salak-schedule.svg?style=flat-square\n[david-url]: https://david-dm.org/SalakJS/salak-schedule\n[download-image]: https://img.shields.io/npm/dm/salak-schedule.svg?style=flat-square\n[download-url]: https://npmjs.org/package/salak-schedule\n\nCron task for salak.\n\n## Feature\n\n- Three mode: single、worker and all. \n  - `single` means the task will be trigger on the only one thread in the only one machine. \n  - `worker` means the task will be trigger on the only one thread in every machine. \n  - `all` means the task will be trigger on every thread\n- Task can trigger service.\n\n## Install\n\n```\nnpm install --save salak-schedule\n```\n\n## Usage\n\n```javascript\nconst schedule = require('salak-schedule')\n\nschedule(options, app)\n```\n\nload schedule from dir `schedule` under every module.\n\n```javascript\nconst { Service } = require('salak')\n\nclass Task extends Service {\n  static timer () {\n    return {\n      enable: true, // default true\n      interval: 1000,\n      type: 'all', // single、all、worker, default 'all'\n      cron: '* * * * * *', // use `cron-parser`\n      cronOptions: {}\n    }\n  }\n\n  async run () { // for the task logic\n\n  }\n}\n```\n\n## API\n\n### schedule options\n\n- Store: for `single` or `worker`，default redisStore\n- prefix: for `single` or `worker`，default 'salakTimer'\n- options: options for Store. default app.redis\n\n### app.getSchedules()\n\n### app.runSchedule(key)\n\n- key: `${module}.${taskfilename}`\n\n### app.closeSchedules()\n\n## Write a store\n\n```javascript\nclass AStore {\n  lock (key, ttl) {}\n  unlock (lock) {}\n}\n\nmodule.exports = AStore\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalakjs%2Fsalak-schedule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalakjs%2Fsalak-schedule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalakjs%2Fsalak-schedule/lists"}