GithubHelp home page GithubHelp logo

lincolnloop / amygdala Goto Github PK

View Code? Open in Web Editor NEW
393.0 393.0 24.0 830 KB

RESTful HTTP client for JavaScript powered web applications

License: BSD 3-Clause "New" or "Revised" License

JavaScript 100.00%

amygdala's People

Contributors

attiasr avatar bkonkle avatar defektive avatar frnk94 avatar mlouro avatar smokku avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amygdala's Issues

Bower support?

Just what I have been looking for. Would there be bower support soon? Thanks

Are remote accesses automatic?

From the docs
// Get the list of active users from the local cache
var users = store.findAll('users', {'active': true});

What happens if the localstorage returns nothing, for example, its the first access, does it trigger a get on the remote resource? Thanks

Support for uri-parameters in API endpoints

Use cases:

  • user has oneToMany coupons, and coupons are retrieved via /api/v1/user/{user_id}/coupons
  • API endpoint requires a parameter (no GET all), /api/v1/notes/{user_id}/

This can be achieved via query parameters right now, but may not be a fit for everyone and requires a certain type of structure for the API endpoints that may not be possible to change.

update() does not use apiUrl and schema url

I have the fallowing instance configured:

this.store = new Amygdala({
      'config' : {
        'apiUrl' : 'http://localhost:8081',
        'idAttribute': 'url',
      },
      'schema' : {
        'plans' : {
          'url' : '/plans/'
        }
      }
    });

this.store.get('plans', {'url': 'myid'}) resolves correctly to http://localhost:8081/plans/myid

but

this.store.update('plans', {'url':'myid', data:data}) resolves to http://localhost:8080/myid

The webserver serving the app is running on http://localhost:8080 while a I have the REST API on http://localhost:8081

find doesn't work if ids are numerical

.find('users', 1) doesn't return anything. You need to parse the number in as a string
.find('users', '1')

The find function doesn't have support for numerical ids. Possible to just change line 503

} else if (Object.prototype.toString.call(query) === '[object String]') {

to

} else if (Object.prototype.toString.call(query) === '[object String]' || Object.prototype.toString.call(query) === '[object Number]') {

Cheers
Paul

ps nice little library, lots of potential.

How to catch errors

I have deletePlace function in my project. When I send DELETE without authorization to some resource server I've got the error 401, how can I catch errors in amygdala?

this.deletePlace = function(place_id) {
    return store.remove('places', {
        'id': "/" + place_id
    }).done(function() {
        ee.emit('change');
    })
}

Error example caused by lack of authorization

DELETE http://localhost/api/v1/places/qx9143jmj7 401 (Unauthorized)
XHR finished loading: DELETE "http://localhost/api/v1/places/qx9143jmj7"
Uncaught #<XMLHttpRequest>

Unable to build GET /api/users/(id) type urls?

I can't seem to figure out how to build urls that follow the /api/endpoint/(id) pattern. It seems this library does it by doing /api/endpoint?id=1 instead. Does this library not support the former pattern?

Add an option for appending trailing slash

Django will redirect if missing trailing slashes, but this will only work for GET. Redirects will also not work if doing a cross origin request while developing (eg localhost:4000 -> localhost:8000)

Auto-append params and post body values from config

The FR is for auth in mind. Most APIs that use authentication require you to append a token on every request either as a query param or in the post body. Setting that to a variable in the config object would be super convienient for calling an api behind oauth2.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.