refactor api to support multiple resources without needing all code in one file