File tree 2 files changed +20
-8
lines changed
2 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,19 @@ import RoleService from 'controllers/Role/service'
2
2
import cron from 'node-cron'
3
3
import ConstRoles from 'constants/ConstRoles'
4
4
5
- // Run this job every 30 minutes
6
- const GetRoleTask = cron . schedule ( '30 * * * *' , async ( ) => {
7
- const data = await RoleService . getOne ( ConstRoles . ID_UMUM )
8
- console . log ( 'Running task check get role by id' , { data } )
9
- } )
5
+ class RoleJob {
6
+ /**
7
+ * Get Role Task
8
+ */
9
+ public static getRole ( ) {
10
+ // Run this job every 30 minutes
11
+ const task = cron . schedule ( '30 * * * *' , async ( ) => {
12
+ const data = await RoleService . getOne ( ConstRoles . ID_UMUM )
13
+ console . log ( 'Running task check get role by id' , { data } )
14
+ } )
10
15
11
- export { GetRoleTask }
16
+ return task
17
+ }
18
+ }
19
+
20
+ export default RoleJob
Original file line number Diff line number Diff line change 1
- import { GetRoleTask } from 'jobs/RoleJob'
1
+ import RoleJob from 'jobs/RoleJob'
2
2
3
3
function initialJobs ( ) {
4
4
// Role Jobs
5
- GetRoleTask . start ( )
5
+ const getRoleTask = RoleJob . getRole ( )
6
+ getRoleTask . start ( )
7
+
8
+ // Other Jobs
6
9
}
7
10
8
11
export default initialJobs
You can’t perform that action at this time.
0 commit comments