0.1.4 • Published 5 years ago
can-make-rest v0.1.4
can-make-rest
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}"}
// }