prism icon indicating copy to clipboard operation
prism copied to clipboard

Behaviors and state

Open alexec opened this issue 3 years ago • 0 comments

Context

I want complex test fakes for APIs. I want write to affect reads, and I want to define the behavior of the API simulation. I’ve prototyped this in Golang and its very similar to Prism, except:

The CLI takes an additional file named operations.js. This file contained functions that have the the following signature:

(req, ctx) -> resp

The function is stateless. It is supplied the HTTP request and context and returns a HTTP response. I.e. it is a Lambda.

The context gives it access to state.

function listPets(req,ctx) {
  var pets = ctx.db.list("pets/*")
   return {statusCode: 200, body: {pets: pets}}
}

Current Behavior

Expected Behavior

Possible Solution(s)

alexec avatar Sep 18 '22 01:09 alexec