How to Create a Custom API Endpoint in Strapi

Update: We have a plugin now that attempts to give us a UI for some of the use cases: https://market.strapi.io/plugins/strapi-plugin-custom-api