npm.io
1.3.0 • Published 11 years ago

resturlify

Licence
MIT
Version
1.3.0
Deps
0
Vulns
0
Weekly
0

RestUrlify

Consistently Generate Rest URLs

Why?

I wrote this to help transition my team from an RPC-each-call-a-snowflake tendency to REST.

Use Anywhere

This library works in the client and on the server.

Install

bower install resturlify

Or

npm install resturlify
Examples
Constructor
var urlTools = new RestUrlify("http://www.web.com/api");
Simple
urlTools.buildUrl()

Returns: http://www.web.com/api

With Params
urlTools.buildUrl({ 
  resource: 'resource',
  query: {id : 1}
})

Returns: http://www.web.com/api/resource?id=1

Custom Methods
urlTools.buildUrl({
  resource: 'resource',
  id: 1,
  customMethod: 'approve'
})

Returns: http://www.web.com/api/resource/1/approve

Keywords