Task: Implement a small Socket.IO server with a dynamic service router
What you must implement
A Node.js server in /app/server.js that starts a Socket.IO server listening on port 3002.
A simple in-memory service registry with at least one service:
multiply(a, b) => a * b
On client connection, listen for a 'call' event. The payload will be a stringified JSON object with the shape:
{ service: string, params: array }
Behavior:
If the requested service exists in the registry, invoke the function with the provided params and respond via the callback with:
{ response: }
If the requested service does not exist, respond via the callback with:
{ error: { name: 'ROUTE_NOT_FOUND' } }
If the payload cannot be parsed as JSON, respond via the callback with:
{ error: { name: 'PARSE_ERROR' } }
Do not return a response property alongside a successful response (i.e., on success, only { response: ... } should be sent; on error, only { error: ... } should be sent).
The server should remain running and able to handle multiple requests.
How to run
Place the code in /app/server.js.
Ensure dependencies include socket.io (and any standard Node.js modules).
A valid service: { service:'multiply', params:[2,3] } should yield { response: 6 }
An invalid service: { service:'multiply2', params:[2,3] } should yield { error: { name: 'ROUTE_NOT_FOUND' } }
Notes
The test suite requires a server on port 3002 that uses Socket.IO and adheres to the described message format and response structure. You can extend the registry with more services by adding more keys to the registry object.