Giter VIP home page Giter VIP logo

a2-in-memory-web-api's People

Contributors

filipesilva avatar johnpapa avatar wardbell 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

a2-in-memory-web-api's Issues

InMemoryBackendService - Model id as "0" always returns 404 from in-memory-backend-service.js

[x ] bug report

I should be able to mock a fake backend service using a primary id of my model object as "0". Instead, it always returns a "404" error in that case. The cause is an "if" conditional in InMemoryBackendService.prototype.delete method. "0" evaluates as falsey which causes the method to execute "this.createErrorResponse(http_status_codes_1.STATUS.NOT_FOUND...)". It also appears that "put" and "post" have similar issues.

Existing framework code:

InMemoryBackendService.prototype.delete = function (_a) {
        var id = _a.id, collection = _a.collection, collectionName = _a.collectionName, headers = _a.headers;
        if (!id) { //<---- Right here is the issue, id "0" evaluates as "falsey"
            return this.createErrorResponse(http_status_codes_1.STATUS.NOT_FOUND, "Missing \"" + collectionName + "\" id");
        }
        var exists = this.removeById(collection, id);
        return new http_1.ResponseOptions({
            headers: headers,
            status: (exists || !this.config.delete404) ? http_status_codes_1.STATUS.NO_CONTENT : http_status_codes_1.STATUS.NOT_FOUND
        });
    };
  • Angular version: 2.0.0-rc.4
  • Browser: all
  • Language: all

Example of usage

Is there a full repository that shows this in use? I can't get this to work with the information here or in the angular.io docs.

Systemjs independence.

Currently i'm test driving Angular2 on a ES6 project. This project is built using Webpack with babel as loader. I try to install your package using NPM. The problem i'm facing is that importing "a2-in-memory-web-api/core" into my code fails once the application is loaded into the browser because Systemjs is not present. This is because Webpack output do not use Systemjs. I look around for solutions to this problem by looking into the angular2 NPM package code and notice that the code use Commonjs packaging. This means that projects using this package can be built using Webpack or Browserify independently of the use of module definition on the browser. I know i can build a2-in-memory-web-api myself to satisfy my requirements but i think the correct thing here would be to follow Angular2 example on not forcing the user on using a specific module definition on the browser.

If you support this idea i will be glad to help you with a PR. This package is very interesting for me. I may help you with other issues.

complex resource paths

support for

 `/api/customer/32/orders`
 `/api/customer/32/orders/451`
 `/api/customer/address`

Save/restore in-mem store to browser local storage (optional)

Ability to serialize/deserialize locally would facilitate browser refresh scenarios, simulating offline, etc.

On start the in-mem server could check browser storage for a well-known (configurable) named store.
Server will load from there upon startup, falling back to resetDb() if not found.

During the life of the session, in-mem server updates that local store as side-effect of save (CUD) calls.

A call to commands/resetdb would reset the local store to the db initial state..

Probably should have a separate commands/clear-local-storage for that purpose alone.

Why is the response wrapped in a data object?

The wrapping of the GET response in a data object forces the user of this lib to perform the same wrapping in his/her backend. This is sometimes not possible.
Would it be possible to deliver the pure response data for a GET request?

Cool idea Ward :)

If you get to the point where you are looking for contribs, give a yell.

I can think of all kinds of use cases where this could be the answer :)

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.