Package Exports
- compact_model
- compact_model/main.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (compact_model) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Compact Model
Compact Model est un Model Proxy
qui vous permet d'avoir une codebase refactorisée lorsqu'il s'agit de définir vos endpoints et le flux réseau en encapsulant le client axios
.
Plugins
- axios
- dotenv
Installation
First install Node.js then :
npm install compact_model
Importing
// Using Node.js `require()`
const CompactModel = require('compact_model')
Overview
- Create
.env
file configure
PROTOCOLE = http
DOMAINE = 127.0.0.1 // or example.com
PORT = 8000
API_ROUTE = /api/
Our backend generates this url http://127.0.0.1:8000/api/
- Example create file index.js
const CompactModel = require('compact_model');
class Product extends CompactModel{}
const product = new Product();
product.list = "";
const {get} = product.method();
//endpoints http://127.0.0.1:8000/api/product/
get.then(res=>{
console.log(res.data);
}).catch(err=>{
console.log(err);
});
Our backend generates the name of the class as an API route within the collection of the extended ModelCompact class.
Default value endpoints
list = "/all";
detail = "/detail/:id";
create = "/store";
destory = "/delete/:id";
update = "/update/:id";