Socket
Socket
Sign inDemoInstall

can-make-rest

Package Overview
Dependencies
3
Maintainers
4
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    can-make-rest

Make restful urls and methods from a resource


Version published
Weekly downloads
3K
decreased by-23.61%
Maintainers
4
Install size
246 kB
Created
Weekly downloads
 

Readme

Source

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}"}
//  }

Keywords

FAQs

Last updated on 21 Aug 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc