Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 71 additions & 1 deletion integrations/sample-app/app/boot/sp/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { QueueJobs } from '#jobs/job';
import { UserDbRepository } from '#repositories/userDbRepository';
import { UserService } from '#services/index';
import { AuthService } from '#services/auth';
import { ScheduleServiceTest } from '#services/schedule';
import { Schedule } from '@intentjs/core/schedule';

export class AppServiceProvider extends ServiceProvider {
/**
Expand All @@ -29,10 +31,78 @@ export class AppServiceProvider extends ServiceProvider {
this.bind(QueueJobs);

this.bind(OrderPlacedListener);

this.bind(ScheduleServiceTest);
}

/**
* Bootstrap any application service here.
*/
boot(app: IntentApplicationContext) {}
boot(app: IntentApplicationContext) {
/**
* Schedule Intent Command to run daily.
*/

Schedule.exec('ls -la')
.everyTwoSeconds()
.appendOutputToFile('output.txt')
.emailOutputTo('vinayak@tryhanalabs.com')
.run();

// Schedule.command('send:email')
// // .days([Schedule.MONDAY, Schedule.THURSDAY])
// .hourly()
// .timezone('America/Chicago')
// .between('8:00', '17:00')
// .run();

/**
* Simple callback, with lifecycle methods `before` and `after`.
*/
// Schedule.call(() => {
// console.log('inside the schedule method');
// return 'hello';
// })
// .purpose('sample scheduler')
// .before(() => console.log('this will run before the cron'))
// .after((output: any) =>
// console.log('this will run after the cron', output),
// )
// .onSuccess((result) =>
// console.log('this will run on success the cron', result),
// )
// .onFailure((error) =>
// console.log('this will run on failure the cron', error),
// )
// // .pingBefore('https://webhook.site/79dcb789-869b-459d-9ba9-638aae449328')
// .thenPing('https://webhook.site/79dcb789-869b-459d-9ba9-638aae449328')
// .weekends()
// .everyTwoSeconds()
// // .pingOnSuccess('https://webhook.site/79dcb789-869b-459d-9ba9-638aae449328')
// .when(() => true)
// .appendOutputToFile('output.txt')
// .run();

/**
* Running a job every day at 5AM.
*/
// Schedule.job({
// job: 'process_abandoned_cart',
// data: { from: '2024-04-16', to: '2024-04-17' },
// })
// .purpose('cron dispatching job every day at 5AM')
// .everyFiveSeconds()
// .weekends()
// .run();

// Schedule.command('emails:send')
// .daily()
// .onSuccess((result) => {
// console.log('emails:send on success', result);
// })
// .onFailure((error: Error) => {
// console.log('emails:send on failure', error);
// })
// .run();
}
}
9 changes: 9 additions & 0 deletions integrations/sample-app/app/services/schedule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Injectable } from '@intentjs/core';
@Injectable()
export class ScheduleServiceTest {
constructor() {}

async handle() {
console.log('inside the handle method');
}
}
6 changes: 3 additions & 3 deletions integrations/sample-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@aws-sdk/client-s3": "^3.689.0",
"@aws-sdk/credential-providers": "^3.687.0",
"@aws-sdk/s3-request-presigner": "^3.689.0",
"@intentjs/core": "workspace:*",
"@intentjs/core": "*",
"bcrypt": "^5.1.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
Expand All @@ -66,8 +66,8 @@
"winston": "^3.14.2"
},
"devDependencies": {
"@intentjs/cli": "workspace:*",
"@intentjs/tooling": "workspace:*",
"@intentjs/cli": "*",
"@intentjs/tooling": "*",
"@nestjs/testing": "^10.0.0",
"@rollup/plugin-typescript": "^12.1.2",
"@rspack/cli": "^1.2.8",
Expand Down
Loading
Loading