{"id":18523620,"url":"https://github.com/mongoosejs/task","last_synced_at":"2025-08-09T22:09:52.531Z","repository":{"id":65541433,"uuid":"562555739","full_name":"mongoosejs/task","owner":"mongoosejs","description":"Scheduled tasks with Mongoose","archived":false,"fork":false,"pushed_at":"2025-01-28T15:19:08.000Z","size":31,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-25T07:22:02.384Z","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/mongoosejs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-06T17:59:49.000Z","updated_at":"2025-01-28T15:19:11.000Z","dependencies_parsed_at":"2023-01-28T09:45:25.289Z","dependency_job_id":"50784ff8-8e0d-4497-a517-05916a809276","html_url":"https://github.com/mongoosejs/task","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"2d613d5afafccc6ae77c24ab08d5fbefb38714dd"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/mongoosejs/task","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Ftask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Ftask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Ftask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Ftask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongoosejs","download_url":"https://codeload.github.com/mongoosejs/task/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Ftask/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269645505,"owners_count":24452747,"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","status":"online","status_checked_at":"2025-08-09T02:00:10.424Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-06T17:36:35.199Z","updated_at":"2025-08-09T22:09:52.511Z","avatar_url":"https://github.com/mongoosejs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# task\nScheduled tasks with Mongoose\n\n## Getting Started\n\nRequires Node \u003e= 14 and Mongoose \u003e= 6.7.0\n\n```javascript\nconst mongoose = require('mongoose');\n\n// Task is a Mongoose model that has several helpful methods and statics\n// for working with scheduled tasks.\nconst Task = require('@mongoosejs/task')();\n\n// Register a handler for a named task and start polling for `sayHello` tasks\nTask.registerHandler('sayHello', function sayHello() {\n  console.log('Hello, World!');\n});\nTask.startPolling();\n\n// Will print 'Hello, World!' after approximately 1 second\nawait Task.schedule('sayHello', new Date(Date.now() + 1000));\n```\n\n## Params\n\nThe 2nd param to `Task.schedule()` is an object that this framework will call the handler function with.\n\n```javascript\nTask.registerHandler('sayHello', function sayHello(params) {\n  console.log(`Hello, ${params.name}!`);\n});\n\n// Will print 'Hello, Friend!' after approximately 1 second\nawait Task.schedule(\n  'sayHello',\n  new Date(Date.now() + 1000),\n  { name: 'Friend' }\n);\n```\n\n## Repeating Tasks\n\nThe 3rd param to `Task.schedule()` is called `repeatAfterMS`.\nIf `repeatAfterMS` is set, this framework will immediately reschedule the task to run after `repeatAfterMS` once the original task is done.\n\n```javascript\nTask.registerHandler('sayHello', function sayHello(params) {\n  console.log(`Hello, ${params.name}!`);\n});\n\n// Will print 'Hello, Friend!' every 5 seconds, after a 1 second\n// initial delay\nawait Task.schedule(\n  'sayHello',\n  new Date(Date.now() + 1000),\n  { name: 'Friend' },\n  5000\n);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoosejs%2Ftask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongoosejs%2Ftask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoosejs%2Ftask/lists"}