@@ -11,11 +11,11 @@ const telemetryObject = { type: "notificationChannel", ver: "1.0.0" };
1111
1212const createHandler = async ( request : Request , response : Response , next : NextFunction ) => {
1313 try {
14- const payload = request . body ;
14+ const body = _ . get ( request , " body" ) ;
1515 const userID = ( request as any ) ?. userID ;
16- _ . set ( payload , "created_by" , userID ) ;
17- _ . set ( payload , "updated_by" , userID ) ;
18- const notificationBody = await Notification . create ( payload ) ;
16+ _ . set ( body , "created_by" , userID ) ;
17+ _ . set ( body , "updated_by" , userID ) ;
18+ const notificationBody = await Notification . create ( body ) ;
1919 updateTelemetryAuditEvent ( { request, object : { id : notificationBody ?. dataValues ?. id , ...telemetryObject } } ) ;
2020 ResponseHandler . successResponse ( request , response , { status : httpStatus . OK , data : { id : notificationBody . dataValues . id } } )
2121 } catch ( err ) {
@@ -26,8 +26,8 @@ const createHandler = async (request: Request, response: Response, next: NextFun
2626
2727const updateHandler = async ( request : Request , response : Response , next : NextFunction ) => {
2828 try {
29- const { id } = request . params ;
30- const updatedPayload = request . body ;
29+ const id = _ . get ( request , ' params.id' ) ;
30+ const updatedPayload = _ . get ( request , ' body' ) ;
3131 const notificationPayloadModel = await Notification . findOne ( { where : { id } } ) ;
3232 const notificationPayload = notificationPayloadModel ?. toJSON ( ) ;
3333 if ( ! notificationPayload ) return next ( { message : httpStatus [ httpStatus . NOT_FOUND ] , statusCode : httpStatus . NOT_FOUND } ) ;
@@ -47,7 +47,7 @@ const updateHandler = async (request: Request, response: Response, next: NextFun
4747
4848const listHandler = async ( request : Request , response : Response , next : NextFunction ) => {
4949 try {
50- const { limit, filters, offset } = request . body ?. request || { } ;
50+ const { limit, filters, offset } = _ . get ( request . body , ' request' , { } ) ;
5151 const notifications = await Notification . findAll ( { limit : limit , offset : offset , ...( filters && { where : filters } ) } ) ;
5252 const count = _ . get ( notifications , "length" ) ;
5353 ResponseHandler . successResponse ( request , response , { status : httpStatus . OK , data : { notifications, ...( count && { count } ) } } ) ;
@@ -59,7 +59,7 @@ const listHandler = async (request: Request, response: Response, next: NextFunct
5959
6060const fetchHandler = async ( request : Request , response : Response , next : NextFunction ) => {
6161 try {
62- const { id } = request . params ;
62+ const id = _ . get ( request , ' params.id' ) ;
6363 const notificationPayloadModel = await Notification . findOne ( { where : { id } } ) ;
6464 const notificationPayload = notificationPayloadModel ?. toJSON ( ) ;
6565 if ( ! notificationPayloadModel ) return next ( { message : httpStatus [ httpStatus . NOT_FOUND ] , statusCode : httpStatus . NOT_FOUND } ) ;
@@ -73,7 +73,7 @@ const fetchHandler = async (request: Request, response: Response, next: NextFunc
7373
7474const retireHandler = async ( request : Request , response : Response , next : NextFunction ) => {
7575 try {
76- const { id } = request . params ;
76+ const id = _ . get ( request , ' params.id' ) ;
7777 const notificationPayloadModel = await Notification . findOne ( { where : { id } } )
7878 const notificationPayload = notificationPayloadModel ?. toJSON ( ) ;
7979 if ( ! notificationPayload ) return next ( { message : httpStatus [ httpStatus . NOT_FOUND ] , statusCode : httpStatus . NOT_FOUND } ) ;
@@ -90,7 +90,7 @@ const retireHandler = async (request: Request, response: Response, next: NextFun
9090
9191const publishHandler = async ( request : Request , response : Response , next : NextFunction ) => {
9292 try {
93- const { id } = request . params ;
93+ const id = _ . get ( request , ' params.id' ) ;
9494 const notificationPayloadModel = await Notification . findOne ( { where : { id } } )
9595 const notificationPayload = notificationPayloadModel ?. toJSON ( ) ;
9696 if ( ! notificationPayload ) return next ( { message : httpStatus [ httpStatus . NOT_FOUND ] , statusCode : httpStatus . NOT_FOUND } ) ;
@@ -108,7 +108,7 @@ const publishHandler = async (request: Request, response: Response, next: NextFu
108108
109109const testNotifationChannelHandler = async ( request : Request , response : Response , next : NextFunction ) => {
110110 try {
111- const { message = "Hello Obsrv" , payload = { } } = request . body ;
111+ const { message = "Hello Obsrv" , payload = { } } = _ . get ( request , ' body' ) ;
112112 const { id } = payload ;
113113 if ( id ) {
114114 const notificationPayloadModel = await Notification . findOne ( { where : { id } } )
0 commit comments