{"id":18519221,"url":"https://github.com/alaricode/nestjs-cron","last_synced_at":"2025-04-09T08:32:09.254Z","repository":{"id":45991218,"uuid":"218243845","full_name":"AlariCode/nestjs-cron","owner":"AlariCode","description":"NestJS cron package allows you easily setup cron for your controllers or services","archived":false,"fork":false,"pushed_at":"2023-05-07T03:38:25.000Z","size":298,"stargazers_count":15,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T04:04:58.589Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://alariblog.ru/","language":"TypeScript","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/AlariCode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-10-29T08:56:31.000Z","updated_at":"2023-04-13T18:58:56.000Z","dependencies_parsed_at":"2024-12-01T04:31:04.623Z","dependency_job_id":"d58e12a4-b028-44bc-a620-4f28ce038e07","html_url":"https://github.com/AlariCode/nestjs-cron","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.25,"last_synced_commit":"40eabc60a73c740fcad17cf8934ea3945cc02a4e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlariCode%2Fnestjs-cron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlariCode%2Fnestjs-cron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlariCode%2Fnestjs-cron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlariCode%2Fnestjs-cron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlariCode","download_url":"https://codeload.github.com/AlariCode/nestjs-cron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248003292,"owners_count":21031765,"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-06T17:15:43.894Z","updated_at":"2025-04-09T08:32:08.896Z","avatar_url":"https://github.com/AlariCode.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NestJS cron Module\n\n![alt cover](https://github.com/AlariCode/nestjs-cron/raw/master/img/logo.jpg)\n\n**More NestJS libs on [alariblog.ru](https://alariblog.ru)**\n\n[![npm version](https://badgen.net/npm/v/nestjs-cron)](https://www.npmjs.com/package/nestjs-cron)\n[![npm version](https://badgen.net/npm/license/nestjs-cron)](https://www.npmjs.com/package/nestjs-cron)\n[![npm version](https://badgen.net/github/open-issues/AlariCode/nestjs-cron)](https://github.com/AlariCode/nestjs-cron/issues)\n[![npm version](https://badgen.net/github/prs/AlariCode/nestjs-cron)](https://github.com/AlariCode/nestjs-cron/pulls)\n\nNestJS cron package allows you easily setup cron for your controllers or services.\n\n```bash\nnpm i nestjs-cron\n```\n\nTo use cron, decorate your class with `@Scheduled()` and method with `@Cron()`.\nYour class has to be a provider or a controller that is declared in any module.\n\n```javascript\nimport { Cron, Scheduled } from 'nestjs-cron';\n\n@Injectable()\n@Scheduled()\nexport class MyClass {\n\t@Cron('* * * * * *')\n\tasync myMethod() {\n\t\t//...\n\t}\n}\n```\n\n`'* * * * * *'` - is a standart cron notation. In this example it will be triggered every second.\nAdditionaly you can use options:\n\n```javascript\n@Cron('* * * * * *', {\n\tlaunchOnInit: true,\n\tsync: true,\n})\n```\n\n-   launchOnInit - Launch job one time right after start\n-   sync - Wait for method to finish before launching next tick if your function takes more time then cron.\n\n## Cron Intercepter\n\nTo intercept cron you can use `@CronIntercepter` decorator. You pass class that implements `CronIntercepterClass` as a parameter. It has one `intercept` method that returns `Promise\u003cboolean\u003e`.\n\n```javascript\nexport class MyIntercepter implements CronIntercepterClass {\n\tasync intercept() {\n\t\treturn false;\n\t}\n}\n```\n\nUsage example:\n\n```javascript\n@Scheduled()\n@Injectable()\nexport class AppService {\n\t@CronIntercepter(MyIntercepter)\n\t@Cron('* * * * * *')\n\tgetHello() {\n\t\tconsole.log('test');\n\t}\n}\n```\n\nIf `intercept` method returns `true` your cron will run as planned. If false method run will be skipped.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falaricode%2Fnestjs-cron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falaricode%2Fnestjs-cron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falaricode%2Fnestjs-cron/lists"}