This program uses the Express framework to define an API with two endpoints: a POST endpoint to input the endpoint parameters (/endpoint) and a GET endpoint to retrieve the results (/endpoint).
The /endpoint POST endpoint expects a JSON body with three properties: url, name, and score. When a POST request is received, the endpoint parameters are added to the endpoints array.
The /endpoint GET endpoint makes requests to each of the endpoints in the endpoints array and returns a JSON object with the scores for each endpoint. The makeRequests function is called to make the requests and accumulate the scores. If any errors occur during the requests, they are logged to the console.
The startRequests function starts making requests on a fixed interval (in this case, every hour) using the setIntervalAsync function from the set-interval-async library. The interval variable is used to store a reference to the interval so it can be cleared later.
The setTimeout function is used to set a timer for 1 hour after the server starts. When the timer expires, the interval is cleared and the makeRequests function is called one final time to get the final scores.
Note that this program assumes that the endpoint parameters are valid URLs