Added a generic way to define and export api routes to api.js