{"_id":"@dxdeveloperexperience/nest-schedule","_rev":"2-79cda0a1cb5ab42579c475fd6a5c08a5","name":"@dxdeveloperexperience/nest-schedule","dist-tags":{"latest":"0.4.6"},"versions":{"0.4.6":{"name":"@dxdeveloperexperience/nest-schedule","version":"0.4.6","description":"Nest - modern, fast, powerful node.js web framework (@schedule)","author":{"name":"Miaowing","email":"i@zfeng.net"},"license":"MIT","scripts":{"build":"tsc -p tsconfig.json","precommit":"lint-staged","prepublish:npm":"npm run build","publish:npm":"npm publish","test":"ts-node -r tsconfig-paths/register test/TestClient.ts"},"peerDependencies":{"@nestjs/common":"^6.0.5"},"devDependencies":{"@nestjs/common":"^6.0.5","@types/lodash":"^4.14.108","@types/node":"^7.0.41","@types/reflect-metadata":"^0.1.0","husky":"^0.14.3","lint-staged":"^7.0.0","mocha":"^6.0.2","prettier":"^1.11.1","ts-node":"^6.0.0","tsconfig-paths":"^3.3.1","typescript":"^2.8.0"},"repository":{"type":"git","url":"git+https://github.com/miaowing/schedule.git"},"bugs":{"url":"https://github.com/miaowing/schedule/issues"},"homepage":"https://github.com/miaowing/schedule#readme","lint-staged":{"*.ts":["prettier --write","git add"]},"dependencies":{"node-schedule":"^1.3.0","reflect-metadata":"^0.1.12"},"gitHead":"bb5b45b547bc8670dbae132351c83ace1a180497","_id":"@dxdeveloperexperience/nest-schedule@0.4.6","_npmVersion":"6.4.1","_nodeVersion":"10.15.1","_npmUser":{"name":"bastienterrier","email":"bastien.terrier@gmail.com"},"dist":{"integrity":"sha512-kMdys4CXo9iAwaSaZy9LhMvoNuD8TDJCKltq6m9H/VErmuBcuS4+7/p3m8yMjKVAtebG4Rvwz2KBBhnnxLYSuw==","shasum":"116267afd6be42d50be5e598e8487b0a5f22a3f0","tarball":"https://registry.npmjs.org/@dxdeveloperexperience/nest-schedule/-/nest-schedule-0.4.6.tgz","fileCount":22,"unpackedSize":86961,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJct1HlCRA9TVsSAnZWagAARPwQAInOd/aCSGYBfz3Smj0I\ndM4EdZWjA1xzTFl3A7fI4TGS5nJ2zrnMrtDlgU3iHULRB+5960XWLyh6/0X0\n0e42BKPLHqMjq3js3/4UupzENDzsoVfZYpxC96g/E7ZG3gaf8IreeH33nA5J\nLTgfiGL6PluALsGbWdDlSChW8mY8XtUM36exk6+W7TmWZxtsAvuuvU5fETVi\ngGUSBmZp0jn6etisOAu4r1ocmNskPD9VqK0lhIKpR5Q5NNs8bm0Gwsoz/M8f\nG1rTzbHYqMRxDtfLxUNF7uQ0SfOy51gO/+yF9qLfuh6u6gZvW3w7r5PPAyBh\n/r6gIiclNK4LwnkyRlexF0Mwmnz0esRXY7gRA3d2iMwoputtAyZtNNnabp5S\nZAajzRpGsqBO94CQ2k639nng/z33VVFgBXUtt2wjVVeadV2G9RIc0kuQuqXC\n2+LqlSkSI9c7AeaNCYmzQtVzfWu1JeQYgFIvjW3m3eBlCjZrp23zI0Q1juzk\na6MK27Nf9bduiAlU40dRx0UzcLDiXGtpuL7oJYHb0HEnlUw0Vcb41wSFT7li\ngGyGYALeEYs5SddTffxY6fpH0oKKXc84zA8bnh9zz8Cd4UUamEyr90m7OAXO\n4AhD/RKGTTteAH+QYOsqjmDJBodL2gOPmAtUjEkcanUpxUd2M6z2JrV4UrjB\nZiyd\r\n=bNy8\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEFUHj9W5VQpS8bZ4GAOYtPKUp8FOqzTPSGiIXHVFCAlAiBCwaZtWn4uO0TWVSOIUW3dTBdX5g+CoAxJtN+PQ9EqQA=="}]},"maintainers":[{"name":"bastienterrier","email":"bastien.terrier@gmail.com"},{"name":"emmanueldemey","email":"demey.emmanuel@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nest-schedule_0.4.6_1555517924813_0.8335058732001788"},"_hasShrinkwrap":false}},"time":{"created":"2019-04-17T16:18:44.632Z","0.4.6":"2019-04-17T16:18:45.053Z","modified":"2022-04-05T06:14:08.428Z"},"maintainers":[{"email":"greenig1na@gmail.com","name":"ig1na"},{"email":"bastien.terrier@gmail.com","name":"bastienterrier"},{"email":"demey.emmanuel@gmail.com","name":"emmanueldemey"}],"description":"Nest - modern, fast, powerful node.js web framework (@schedule)","homepage":"https://github.com/miaowing/schedule#readme","repository":{"type":"git","url":"git+https://github.com/miaowing/schedule.git"},"author":{"name":"Miaowing","email":"i@zfeng.net"},"bugs":{"url":"https://github.com/miaowing/schedule/issues"},"license":"MIT","readme":"<p align=\"center\">\r\n  <a href=\"http://nestjs.com/\" target=\"blank\"><img src=\"https://nestjs.com/img/logo_text.svg\" width=\"320\" alt=\"Nest Logo\" /></a>\r\n</p>\r\n\r\n## Description\r\n\r\nThis is a [Nest](https://github.com/nestjs/nest) module for using decorator schedule a job.\r\n\r\n\r\n## Installation\r\n\r\n```bash\r\n$ npm i --save nest-schedule\r\n```\r\n\r\n\r\n## Usage\r\n\r\n```typescript\r\nimport { Injectable, LoggerService } from '@nestjs/common';\r\nimport { Cron, Interval, Timeout, NestSchedule } from 'nest-schedule';\r\n\r\n@Injectable()\r\nexport class ScheduleService extends NestSchedule {    \r\n  @Cron('0 0 2 * *', {\r\n    startTime: new Date(), \r\n    endTime: new Date(new Date().getTime() + 24 * 60 * 60 * 1000),\r\n    tz: 'Asia/Shanghai',\r\n  })\r\n  async cronJob() {\r\n    console.log('executing cron job');\r\n  }\r\n  \r\n  @Timeout(5000)\r\n  onceJob() {\r\n    console.log('executing once job');\r\n  }\r\n  \r\n  @Interval(2000)\r\n  intervalJob() {\r\n    console.log('executing interval job');\r\n    \r\n    // if you want to cancel the job, you should return true;\r\n    return true;\r\n  }\r\n}\r\n```\r\n\r\n### Distributed Support\r\n\r\n```typescript\r\nimport { Injectable } from '@nestjs/common';\r\nimport { Cron, NestDistributedSchedule } from 'nest-schedule';\r\n\r\n@Injectable()\r\nexport class ScheduleService extends NestDistributedSchedule {  \r\n  async tryLock(method: string) {\r\n    // If try lock fail, you should throw an error.\r\n    throw new Error('try lock fail');\r\n    \r\n    return () => {\r\n      // Release here.\r\n    }\r\n  }\r\n  \r\n  @Cron('0 0 4 * *')\r\n  async cronJob() {\r\n    console.log('executing cron job');\r\n  }\r\n}\r\n```\r\n\r\n### Global Options\r\n\r\n```typescript\r\nimport { LoggerService } from '@nestjs/common';\r\nimport { defaults } from 'nest-schedule';\r\n\r\nexport class NestLogger implements LoggerService {\r\n    log(message: string): any {\r\n        console.log(message);\r\n    }\r\n\r\n    error(message: string, trace: string): any {\r\n        console.error(message, trace);\r\n    }\r\n\r\n    warn(message: string): any {\r\n        console.warn(message);\r\n    }\r\n}\r\n\r\ndefaults.enable = true;\r\ndefaults.logger = new NestLogger();\r\ndefaults.maxRetry = -1;\r\ndefaults.retryInterval = 5000;\r\n```\r\n\r\n\r\n## API\r\n\r\n### BaseOptions\r\n\r\n| field | type | required | description |\r\n| --- | --- | --- | --- |\r\n| enable | boolean | false | default is true, when false, the job will not execute |\r\n| maxRetry | number | false |  the max retry count, default is -1 not retry |\r\n| retryInterval | number | false | the retry interval, default is 5000 |\r\n| logger | LoggerService | false | default is false, only available at defaults |\r\n\r\n### Cron(expression: string, options?: CronOptions | BaseOptions)\r\n\r\n| field | type | required | description |\r\n| --- | --- | --- | --- |\r\n| expression | string | true | the cron expression |\r\n| options.startTime | Date | false | the job's start time |\r\n| options.endTime | Date | false | the job's end time |\r\n| options.tz | string | false | the time zone |\r\n\r\n### Interval(time: number, options?: BaseOptions)\r\n\r\n| field | type | required | description |\r\n| --- | --- | --- | --- |\r\n| time | number | true | millisecond |\r\n| options | object | false | same as common options |\r\n\r\n### Timeout(time: number, options?: BaseOptions)\r\n\r\n| field | type | required | description |\r\n| --- | --- | --- | --- |\r\n| time | number | true | millisecond |\r\n| options | object | false | same as common options |\r\n\r\n\r\n## Stay in touch\r\n\r\n- Author - [miaowing](https://github.com/miaowing)\r\n\r\n## License\r\n\r\n  NestSchedule is [MIT licensed](LICENSE).\r\n","readmeFilename":"README.md"}