wardbell / a2-in-memory-web-api Goto Github PK
View Code? Open in Web Editor NEWAn in-memory web api for demos and tests
License: MIT License
An in-memory web api for demos and tests
License: MIT License
Could this be used for querying a local blockchain?
[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
});
};
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.
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.
support for
`/api/customer/32/orders`
`/api/customer/32/orders/451`
`/api/customer/address`
support for skip and take
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.
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?
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 :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.