fakir

    0.0.2 • Public • Published

    node-fakir

    magic rest client

    NPM

    Description

    You only deal with rest + json + callback-based apps? look no further:

    How it works

    Coffee

    Fakir = require 'fakir'
     
    api = new Fakir
      hello: (msg)    -> "POST $msg TO http://foo.bar"
      price: (ticker) -> "GET http://foo.bar/stock/$ticker"
     
    # and call them! 
    api.hello "world"
     
    # all functions takes a "callback(err, data)" 
    api.price "PEAR"(err, price) -> console.log "PEAR: #{price}"

    JS

    Of course Coffee and JS interfaces are strictly the same, and share the same features:

    var Fakir = require('fakir', true); 
    var api = new Fakir({
        'hello': function (msg) { 
            return "POST $msg TO http://foo.bar";
        },
        'price': function (ticker) { 
            return "GET http://foo.bar/stock/$ticker";
        }
    }, true) // add 'true' at the end to mock/debug the routes
     
    // chaining is supported, but not yet futures: functions are called immediately 
    api.hello("world").price("PEAR", function(err, price) { 
        return console.log("PEAR: #{price}");
    })
     

    Changelog

    0.0.1:

    • moved routes into the Fakir constructor
    • removed add() function
    • fixed a closure bug with the for loop
    • fixed a critical bug with optional callback
    • added an optional mock parameter to test routes
    • various cleaning

    0.0.0: Initial version

    Bitdeli Badge

    Keywords

    none

    Install

    npm i fakir

    DownloadsWeekly Downloads

    0

    Version

    0.0.2

    License

    none

    Last publish

    Collaborators

    • jbilcke