interfake icon indicating copy to clipboard operation
interfake copied to clipboard

Fluent command-line interface

Open basicallydan opened this issue 10 years ago • 3 comments

The JS interface for creating APIs is super easy and clear, but the command line interface can be a bit of a faff.

This:

$ interfake GET /thing 200 {"response":"whatever"} creates POST /other-thing 201 {"hey":"whatup"}

Should produce the same results aas this:

interfake.get('/thing').status(200).body({"response":"whatever"}).creates.post('/other-thing').status(201).body({"hey":"whatup"});
  • [x] Support creating a single endpoint
  • [x] Support creates
  • [ ] Support extends
  • [ ] Support patch

basicallydan avatar Mar 18 '14 10:03 basicallydan

Are there examples of node stuff having these fluent apis?

sebs avatar Apr 25 '14 09:04 sebs

Not as far as I know. It's a bit weird, but I can't see why it shouldn't be possible. I played around with it a little bit a couple of weeks ago, and I think the process essentially needs a state machine which parses the input very similarly to how one would parse a programming language. I wouldn't be surprised if there's a node tool out there for parsing this sort of thing. Possibly Jison

basicallydan avatar Apr 25 '14 09:04 basicallydan

I worked with state machines

sebs avatar Apr 25 '14 11:04 sebs