You need a socket listening on a port and use the socket.on(event) to call the same method your controller is calling.
You can also use a message queue as entry point and make sure both your http calls and socket events dispatch a message, then you consume from your queue and execute the method. This approach is better in terms of scalability, you could later add a new endpoint in a different service and it will trigger the same behavior.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I have a scenario where I want a microservice to listen to HTTP Requests and also to the events emitted from the other service. How can I do that ?
You need a socket listening on a port and use the socket.on(event) to call the same method your controller is calling.
You can also use a message queue as entry point and make sure both your http calls and socket events dispatch a message, then you consume from your queue and execute the method. This approach is better in terms of scalability, you could later add a new endpoint in a different service and it will trigger the same behavior.