I need a controller action that:
- Authorizes the call
- Validates it
- Returns the 202 Accepted status
- Continues processing the request
- Makes a call to external API with the results of previously accepted and now processed request.
First two points are easy, I use AuthGuard
then class-validator
. But I don't know how to return the HTTP response then continue with processing.
As the request consists of an array of (possibly long-running) tasks I thought of using interceptor that uses RxJS to observes the status of tasks and calls external PI upon their completion. However, I have no experience with using RxJS or interceptors (not this way) so I'd really don't know how to leave interceptor's process running but immediately pass control to controller's action.
Also, perhaps there is another, better way? No interceptor but just put all the flow logic in the controller? Some other option?