@@ -11,25 +11,61 @@ import {
11
11
updateAccountConditionExpiryDateHandler ,
12
12
updateEntityConditionExpiryDateHandler ,
13
13
} from './app.controller' ;
14
- import { SetOptionsBody , SetOptionsParams , SetOptionsBodyAndParams } from './utils/schema-utils' ;
14
+ import { SetOptionsBodyAndParams } from './utils/schema-utils' ;
15
+
16
+ const routePrivilege = {
17
+ getAccount : 'GET_V1_EVENT_FLOW_CONTROL_ACCOUNT' ,
18
+ getEntity : 'GET_V1_EVENT_FLOW_CONTROL_ENTITY' ,
19
+ putAccount : 'PUT_V1_EVENT_FLOW_CONTROL_ACCOUNT' ,
20
+ putEntity : 'PUT_V1_EVENT_FLOW_CONTROL_ENTITY' ,
21
+ postAccount : 'POST_V1_EVENT_FLOW_CONTROL_ACCOUNT' ,
22
+ postEntity : 'POST_V1_EVENT_FLOW_CONTROL_ENTITY' ,
23
+ putCache : 'PUT_V1_EVENT_FLOW_CONTROL_CACHE' ,
24
+ getReport : 'GET_V1_GETREPORTBYMSGID' ,
25
+ } ;
15
26
16
27
async function Routes ( fastify : FastifyInstance ) : Promise < void > {
17
28
fastify . get ( '/' , handleHealthCheck ) ;
18
29
fastify . get ( '/health' , handleHealthCheck ) ;
19
- fastify . get ( '/v1/admin/reports/getreportbymsgid' , SetOptionsParams ( reportRequestHandler , 'messageIDSchema' ) ) ;
20
- fastify . get ( '/v1/admin/event-flow-control/entity' , SetOptionsParams ( getConditionHandler , 'queryEntityConditionSchema' ) ) ;
21
- fastify . get ( '/v1/admin/event-flow-control/account' , SetOptionsParams ( getAccountConditionsHandler , 'queryAccountConditionSchema' ) ) ;
22
- fastify . post ( '/v1/admin/event-flow-control/entity' , SetOptionsBody ( postConditionHandlerEntity , 'entityConditionSchema' ) ) ;
23
- fastify . post ( '/v1/admin/event-flow-control/account' , SetOptionsBody ( postConditionHandlerAccount , 'accountConditionSchema' ) ) ;
30
+ fastify . get (
31
+ '/v1/admin/reports/getreportbymsgid' ,
32
+ SetOptionsBodyAndParams ( reportRequestHandler , routePrivilege . getReport , undefined , 'messageIDSchema' ) ,
33
+ ) ;
34
+ fastify . get (
35
+ '/v1/admin/event-flow-control/entity' ,
36
+ SetOptionsBodyAndParams ( getConditionHandler , routePrivilege . getEntity , undefined , 'queryEntityConditionSchema' ) ,
37
+ ) ;
38
+ fastify . get (
39
+ '/v1/admin/event-flow-control/account' ,
40
+ SetOptionsBodyAndParams ( getAccountConditionsHandler , routePrivilege . getAccount , undefined , 'queryAccountConditionSchema' ) ,
41
+ ) ;
42
+ fastify . post (
43
+ '/v1/admin/event-flow-control/entity' ,
44
+ SetOptionsBodyAndParams ( postConditionHandlerEntity , routePrivilege . postEntity , 'entityConditionSchema' ) ,
45
+ ) ;
46
+ fastify . post (
47
+ '/v1/admin/event-flow-control/account' ,
48
+ SetOptionsBodyAndParams ( postConditionHandlerAccount , routePrivilege . postAccount , 'accountConditionSchema' ) ,
49
+ ) ;
24
50
fastify . put (
25
51
'/v1/admin/event-flow-control/entity' ,
26
- SetOptionsBodyAndParams ( updateEntityConditionExpiryDateHandler , 'expireDateTimeSchema' , 'expireEntityConditionSchema' ) ,
52
+ SetOptionsBodyAndParams (
53
+ updateEntityConditionExpiryDateHandler ,
54
+ routePrivilege . putEntity ,
55
+ 'expireDateTimeSchema' ,
56
+ 'expireEntityConditionSchema' ,
57
+ ) ,
27
58
) ;
28
59
fastify . put (
29
60
'/v1/admin/event-flow-control/account' ,
30
- SetOptionsBodyAndParams ( updateAccountConditionExpiryDateHandler , 'expireDateTimeSchema' , 'expireAccountConditionSchema' ) ,
61
+ SetOptionsBodyAndParams (
62
+ updateAccountConditionExpiryDateHandler ,
63
+ routePrivilege . putAccount ,
64
+ 'expireDateTimeSchema' ,
65
+ 'expireAccountConditionSchema' ,
66
+ ) ,
31
67
) ;
32
- fastify . put ( '/v1/admin/event-flow-control/cache' , putRefreshCache ) ;
68
+ fastify . put ( '/v1/admin/event-flow-control/cache' , SetOptionsBodyAndParams ( putRefreshCache , routePrivilege . putCache ) ) ;
33
69
}
34
70
35
71
export default Routes ;
0 commit comments