11import { procedure , router } from "../trpc" ;
22import { z } from "zod" ;
33import { TRPCError } from "@trpc/server" ;
4+ import type { QueueDashScheduler } from "../utils/global.utils" ;
45import { findQueueInCtxOrFail } from "../utils/global.utils" ;
56
67export const schedulerRouter = router ( {
@@ -10,18 +11,23 @@ export const schedulerRouter = router({
1011 queueName : z . string ( ) ,
1112 } ) ,
1213 )
13- . query ( async ( { input : { queueName } , ctx : { queues } } ) => {
14- const queueInCtx = findQueueInCtxOrFail ( { queues, queueName } ) ;
14+ . query (
15+ async ( {
16+ input : { queueName } ,
17+ ctx : { queues } ,
18+ } ) : Promise < QueueDashScheduler [ ] > => {
19+ const queueInCtx = findQueueInCtxOrFail ( { queues, queueName } ) ;
1520
16- if ( queueInCtx . type !== "bullmq" ) {
17- throw new TRPCError ( {
18- code : "BAD_REQUEST" ,
19- message : "Scheduled jobs are only supported for BullMQ queues" ,
20- } ) ;
21- }
21+ if ( queueInCtx . type !== "bullmq" ) {
22+ throw new TRPCError ( {
23+ code : "BAD_REQUEST" ,
24+ message : "Scheduled jobs are only supported for BullMQ queues" ,
25+ } ) ;
26+ }
2227
23- return queueInCtx . queue . getJobSchedulers ( ) ;
24- } ) ,
28+ return queueInCtx . queue . getJobSchedulers ( ) ;
29+ } ,
30+ ) ,
2531
2632 add : procedure
2733 . input (
@@ -98,7 +104,10 @@ export const schedulerRouter = router({
98104 } ) ,
99105 )
100106 . mutation (
101- async ( { input : { jobSchedulerIds, queueName } , ctx : { queues } } ) => {
107+ async ( {
108+ input : { jobSchedulerIds, queueName } ,
109+ ctx : { queues } ,
110+ } ) : Promise < QueueDashScheduler [ ] > => {
102111 const queueInCtx = findQueueInCtxOrFail ( {
103112 queues,
104113 queueName,
0 commit comments