ResourceManager
easy to use model based REST API client
Installation
npm install arekzc-resource
Example
Typescript
// Model of@Reflect public id: number; public title: string; // For this example i use angular $http service but you could// replace it with other with similar interfacelet http = angular;// Registry for new Resource classeslet registry = ;// Create configuration to set defaults for resourceManager servicelet configuration = registry;// Create instance of resource with provided serviceslet resourceManager = http configuration;// Get new resource based on metadata added by Reflect libraryresourceManager;
Javascript
{ thisid = undefined; thistitle = undefined;} Reflect// For this example i use angular $http service but you could// replace it with other with similar interfacevar http = angular;// Registry for new Resource classesvar registry = ;// Create configuration to set defaults for resourceManager servicevar configuration = registry;// Create instance of resource with provided servicesvar resourceManager = http configuration; resourceManager;
API
Metadata
// Required: Define route generator used to generate url for http service// parameters passed in route are fields in model@Reflect
Default resource
let resource = resourceManager; let book = ; bookid = 1;booktitle = 'Harry Potter'; resource;resource;resource;resource;resource;