Endpoint logic separated from the server.js file