File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ interface Consignment {
9
9
_id ?: string ;
10
10
filename : string ;
11
11
blindedutxo : string ;
12
+ ack ?: boolean ;
12
13
}
13
14
14
15
let ds = Datastore . create ( ) ;
@@ -47,4 +48,44 @@ export const loadApiEndpoints = (app: Application): void => {
47
48
res . status ( 500 ) . send ( { success : false } ) ;
48
49
}
49
50
} ) ;
51
+
52
+ app . post ( "/ack" , async ( req : Request , res : Response ) => {
53
+ try {
54
+ if ( ! req . body . blindedutxo ) {
55
+ return res . status ( 500 ) . send ( { success : false } ) ;
56
+ }
57
+ let c : Consignment | null = await ds . findOne ( { blindedutxo : req . body . blindedutxo } ) ;
58
+ if ( ! c ) {
59
+ return res . status ( 500 ) . send ( { success : false } ) ;
60
+ }
61
+ await ds . update ( { blindedutxo : req . body . blindedutxo } , { $set : { ack : true } } , { multi : false } ) ;
62
+ c = await ds . findOne ( { blindedutxo : req . body . blindedutxo } ) ;
63
+
64
+ return res . status ( 200 ) . send ( { success : true } ) ;
65
+ } catch ( error ) {
66
+ res . status ( 500 ) . send ( { success : false } ) ;
67
+ }
68
+ } ) ;
69
+
70
+ app . get ( "/ack" , async ( req : Request , res : Response ) => {
71
+ try {
72
+ if ( ! ! req . query . blindedutxo ) {
73
+ const c : Consignment | null = await ds . findOne ( { blindedutxo : req . query . blindedutxo } ) ;
74
+
75
+ if ( ! c ) {
76
+ return res . status ( 500 ) . send ( { success : false } ) ;
77
+ }
78
+ const ack = ! ! c . ack ;
79
+
80
+ return res . status ( 200 ) . send ( {
81
+ success : true ,
82
+ ack,
83
+ } ) ;
84
+ }
85
+
86
+ res . status ( 500 ) . send ( { success : false } ) ;
87
+ } catch ( error ) {
88
+ res . status ( 500 ) . send ( { success : false } ) ;
89
+ }
90
+ } ) ;
50
91
} ;
Original file line number Diff line number Diff line change
1
+ test
You can’t perform that action at this time.
0 commit comments