File tree Expand file tree Collapse file tree 4 files changed +84
-3
lines changed Expand file tree Collapse file tree 4 files changed +84
-3
lines changed Original file line number Diff line number Diff line change
1
+ import { prisma } from "../client" ;
2
+
3
+ interface GetQueueStatusParams {
4
+ walletAddress ?: string ;
5
+ }
6
+
7
+ export const getQueueStatus = async ( {
8
+ walletAddress,
9
+ } : GetQueueStatusParams ) => {
10
+ const queued = await prisma . transactions . count ( {
11
+ where : {
12
+ fromAddress : walletAddress ?. toLowerCase ( ) ,
13
+ processedAt : null ,
14
+ errorMessage : null ,
15
+ } ,
16
+ } ) ;
17
+
18
+ const pending = await prisma . transactions . count ( {
19
+ where : {
20
+ fromAddress : walletAddress ?. toLowerCase ( ) ,
21
+ sentAt : {
22
+ not : null ,
23
+ } ,
24
+ minedAt : null ,
25
+ errorMessage : null ,
26
+ } ,
27
+ } ) ;
28
+
29
+ return {
30
+ queued,
31
+ pending,
32
+ } ;
33
+ } ;
Original file line number Diff line number Diff line change @@ -96,9 +96,10 @@ import { revokeRelayer } from "./relayer/revoke";
96
96
import { getAllTransactions } from "./backend-wallet/getTransactions" ;
97
97
import { sendTransactionBatch } from "./backend-wallet/sendTransactionBatch" ;
98
98
import { withdraw } from "./backend-wallet/withdraw" ;
99
- import { healthCheck } from "./health" ;
100
99
import { home } from "./home" ;
101
100
import { updateRelayer } from "./relayer/update" ;
101
+ import { healthCheck } from "./system/health" ;
102
+ import { queueStatus } from "./system/queue" ;
102
103
import { checkGroupStatus } from "./transaction/group" ;
103
104
import { sendSignedTransaction } from "./transaction/sendSignedTx" ;
104
105
import { sendSignedUserOp } from "./transaction/sendSignedUserOp" ;
@@ -208,4 +209,5 @@ export const withRoutes = async (fastify: FastifyInstance) => {
208
209
// System
209
210
await fastify . register ( home ) ;
210
211
await fastify . register ( healthCheck ) ;
212
+ await fastify . register ( queueStatus ) ;
211
213
} ;
Original file line number Diff line number Diff line change 1
1
import { Static , Type } from "@sinclair/typebox" ;
2
2
import { FastifyInstance } from "fastify" ;
3
3
import { StatusCodes } from "http-status-codes" ;
4
- import { isDatabaseHealthy } from "../../db/client" ;
4
+ import { isDatabaseHealthy } from "../../../ db/client" ;
5
5
6
6
const ReplySchemaOk = Type . Object ( {
7
7
status : Type . String ( ) ,
@@ -19,7 +19,7 @@ export async function healthCheck(fastify: FastifyInstance) {
19
19
Reply : Static < typeof ReplySchema > ;
20
20
} > ( {
21
21
method : "GET" ,
22
- url : "/health" ,
22
+ url : "/system/ health" ,
23
23
schema : {
24
24
summary : "Check health" ,
25
25
description : "Check the system health of Engine" ,
Original file line number Diff line number Diff line change
1
+ import { Static , Type } from "@sinclair/typebox" ;
2
+ import { FastifyInstance } from "fastify" ;
3
+ import { StatusCodes } from "http-status-codes" ;
4
+ import { getQueueStatus } from "../../../db/transactions/getQueueStatus" ;
5
+
6
+ const QuerySchema = Type . Object ( {
7
+ walletAddress : Type . Optional ( Type . String ( ) ) ,
8
+ } ) ;
9
+
10
+ const ReplySchema = Type . Object ( {
11
+ result : Type . Object ( {
12
+ queued : Type . Number ( ) ,
13
+ pending : Type . Number ( ) ,
14
+ } ) ,
15
+ } ) ;
16
+
17
+ export async function queueStatus ( fastify : FastifyInstance ) {
18
+ fastify . route < {
19
+ Querystring : Static < typeof QuerySchema > ;
20
+ Reply : Static < typeof ReplySchema > ;
21
+ } > ( {
22
+ method : "GET" ,
23
+ url : "/system/queue" ,
24
+ schema : {
25
+ summary : "Check queue status" ,
26
+ description : "Check the status of the queue" ,
27
+ tags : [ "System" ] ,
28
+ operationId : "queueStatus" ,
29
+ querystring : QuerySchema ,
30
+ response : {
31
+ [ StatusCodes . OK ] : ReplySchema ,
32
+ } ,
33
+ } ,
34
+ handler : async ( req , res ) => {
35
+ const { walletAddress } = req . query ;
36
+
37
+ const { queued, pending } = await getQueueStatus ( { walletAddress } ) ;
38
+ res . status ( StatusCodes . OK ) . send ( {
39
+ result : {
40
+ queued,
41
+ pending,
42
+ } ,
43
+ } ) ;
44
+ } ,
45
+ } ) ;
46
+ }
You can’t perform that action at this time.
0 commit comments