Create a CRUD resource complete with HTTP routes and state persistance.

Using the function is as easy as:

  1. importing it,
  2. specifying a name for the resource (in Settings -> Parameters), and
  3. emit a response.

In Settings -> Parameters additional settings can be specified. You may specify a schema that the resource should conform to, which CRUD actions to enable, and opt in to use LoLo authentication/authorization. Please consult the Settings -> Parameters for documentation on each setting.


A action where no error (auth, validation, etc) produces an event that is routed to the out port.

Input/Output Format

The produced event is an object. The object has properties associated with the HTTP request that triggered the action. (method, path, params, query, body and headers.)

All events also has the property crud which is an object that has two properties: action and resource. action is one of 'read', 'list', 'update', 'patch', 'create', or 'delete'. resource is a string hand holds the resource name specified in Settings -> Parameters.

All events also holds a pre-built HTTP response in the response property, with a status property representing a suggested HTTP status and a body property representing a suggested HTTP response body. The suggestions are informed by the action performed.

If authentication is specified to be used in Settings -> Parameters, then a session property is also set on the event. Please consult LoLo API Auth for details on the format of this property.

If a specific resource is accessed by it's ID, then the event will have a resource and a resourceKey property. The resourceKey property is a string that is used to access the resource in LoLo state. The resource property holds the accessed resource. This property is also present in case of a create action.

When a list action is performed, the items property is set on the event. This property is an array of all resources.


This functions saves the resources it manages in the global state.

The keys used are constructed from the resource name and the resource ID joined with the string 's:' inbetween. E.g. if the resource is named user and a specific instance has the ID 046b4cf2-cf1f-4b07-b7ee-97e238ae7ae4, then the that instance is saved in the state with the key users:046b4cf2-cf1f-4b07-b7ee-97e238ae7ae4.

HTTP Routes

This function may register the following HTTP routes:

  • GET /${resource}s,
  • GET /${resource}s/:id,
  • POST /${resource}s,
  • PUT /${resource}s/:id,
  • PATCH /${resource}s/:id, and
  • DELETE /${resource}s/:id.

Each route corresponds to a action that can be toggled in Settings -> Parameters, e.g. GET /${resource}s is only registered if the List action is enabled.

${resource} is the resource name specified in Settings -> Parameters. :id is an ID for one of the resources handled by this function.


This function listen for events named response. Please consult the documentation for HTTP Trigger for more details on this event.