Building a reusable REST api framework for Salesforce.com apps

gregheartcloud
3 min readApr 1, 2023

--

The life of an independent consultant

For my next feature its time to build my production ready version of my api handler. I’m very proud of this framework. I have been building apis on Salesforce for 10+ years and I have just the coolest framework that I use for managing custom APIs on the platform.

Here are the requirements:

  1. Enterprise ready framework (think something like Express or Koa for Salesforce) for creating salesforce api. My goal is to make the framework compatible with modern api tools like swagger.
  2. New APIs can be dynamically added and injected to the platform using metadata setup and a simple handler class that will add it to the correct route on the API
  3. API is an INTERNAL implementation on the platform. This supports my architectural principal of API driven development. The api’s can be called internally from other apex classes, or via a web front end via remote methods or aura enabled classes.
  4. API is available to other javascript framework apps running applications hosted on Salesforce.com (Reactforce anyone?) via remote methods or lightning messaging
  5. API is privately available via external Rest Endpoints on the platform for any authenticated user.
  6. API is publically available via a force.com site that has been properly configured (webhooks anyone?)
  7. Visualforce test harness
  8. Lightning component test harness to access the API from lightning
  9. Robust Logging on all api requests with the fine grained control over the logging

Future Roadmap Requirements:

  1. APIs can be generated and added to the framework very easily. Future tooling can be built on top of this to allow those APIs to be quickly generated and added to the stack.
  2. Denial of Service and other tools to support monitoring and eventing

Why all this work?

  1. First of all my goal in life is to retire as a self-made independent software architect who gives away my secrets for free and this is a big one
  2. My work on the Reactforce project has required me to optimize the backend work that is ever required to get a new Reactforce application up and running. The proper API driven development model is just good separation of concerns anyway. My projects that are designed on api driven development are incredibly clean, robust, and easy to maintain.
  3. The architecture for this API is globally scalable across your salesforce implementation. This puts Salesforce.com as the primary owner of critical data AND providing enterprise tooling that is necessary to scale a large app (sorry mulesoft but there is a sexier kid in town!)

Here is what I will be building this weekend!

This feature shall hence be known as feature/ENT-19

Happy Coding…. I’ll update this entry when its done…

--

--