0.1.4 • Published 5 years ago

can-make-rest v0.1.4

Weekly downloads
1,865
License
MIT
Repository
github
Last release
5 years ago

can-make-rest

Build Status Greenkeeper badge

Make restful urls and methods from a resource.

makeRest( resourceUrl[, uniqueProperty])

Provide it an "items" resource url and the unique property name and it returns an object with CRUD HTTP methods and templated urls.

makeRest( "/todos", "ID" ); //=> {
//    getData: {method:"GET", url: "/todos/{ID}"},
//    getListData: {method:"GET", url: "/todos"},
//    createData: {method:"POST", url: "/todos"},
//    updateData: {method:"PUT", url: "/todos/{ID}"},
//    destroyData: {method:"DELETE", url: "/todos/{ID}"}
//  }

If a templated "item" resource URL is provided, it will be able to infer the unique property name.

makeRest( "/todos/{_id}" ); //=> {
//    getData: {method:"GET", url: "/todos/{_id}"},
//    getListData: {method:"GET", url: "/todos"},
//    createData: {method:"POST", url: "/todos"},
//    updateData: {method:"PUT", url: "/todos/{_id}"},
//    destroyData: {method:"DELETE", url: "/todos/{_id}"}
//  }
1.0.0-0

5 years ago

0.1.5-0

5 years ago

0.1.4

5 years ago

0.1.3

6 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.1.0-pre.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago