connect-rest
Advanced tools
Comparing version 0.0.29 to 0.0.30
@@ -6,3 +6,3 @@ /* | ||
*/ | ||
var VERSION = '0.0.29'; | ||
var VERSION = '0.0.30'; | ||
@@ -9,0 +9,0 @@ var connect = require('connect'); |
{ | ||
"name": "connect-rest", | ||
"version": "0.0.29", | ||
"version": "0.0.30", | ||
"description": "RESTful web services middleware for Connect.", | ||
@@ -49,4 +49,4 @@ "keywords": [ | ||
"readme": "README.md", | ||
"_id": "connect-rest@0.0.29", | ||
"_from": "connect-rest@>=0.0.29" | ||
"_id": "connect-rest@0.0.30", | ||
"_from": "connect-rest@>=0.0.30" | ||
} |
@@ -12,2 +12,6 @@ [connect-rest](https://github.com/imrefazekas/connect-rest) is a middleware for [connect](http://www.senchalabs.org/connect/) for building REST APIs providing service discovery and path-based parameter mapping and "reflective" publishing and node domains as well. | ||
# Installation | ||
$ npm install connect-rest | ||
## Features: | ||
@@ -33,2 +37,4 @@ - [Assign](#assign) | ||
- [Answering async rest requests](#answering-async-rest-requests) | ||
- [Usage](#usage) | ||
- [Changelog](#changelog) | ||
@@ -44,3 +50,3 @@ ## Assign | ||
console.log( 'Received JSON object:' + JSON.stringify( content ) ); | ||
return 'ok'; | ||
callback(null, 'ok'); | ||
} | ||
@@ -72,2 +78,22 @@ rest.post( [ { path: '/shake', version: '>=2.0.0' }, { path: '/twist', version: '>=2.1.1' } ], service ); | ||
Mandatory variables: | ||
{ path: '/make/:uid', version: '>=1.0.0' } | ||
Optional path: | ||
{ path: '/delete/?id', version: '>=1.0.0' } | ||
{ path: '/delete/?id/?date', version: '>=1.0.0' } | ||
General path: | ||
{ path: '/rent/*bookTitle', version: '>=1.0.0' } | ||
Complex path: | ||
[ { path: '/rent/?isbn/*bookTitle', version: '<2.0.0' }, { path: '/borrow/:uid/?isbn/?bookTitle', version: '>=2.1.1' } ] | ||
[Back to Feature list](#features) | ||
@@ -175,2 +201,14 @@ | ||
You can make rather complex mixtures of those options as well: | ||
'/borrow/:uid/?isbn/:bookTitle' | ||
One can call this with uri: | ||
'borrow/2/AliceInWonderland' or 'borrow/2/HG1232131/AliceInWonderland' | ||
The logic how [connect-rest](https://github.com/imrefazekas/connect-rest) is managing parameter replacement is the following: | ||
The parameters are processed in the path defintion order and any missing optional parameter will be filled with empty strings to keep the order of them keeping in sight all mandatory parameters put after the optional ones. | ||
[Back to Feature list](#features) | ||
@@ -183,2 +221,11 @@ | ||
This value can be set through the option object as well: | ||
var options = { | ||
'context': '/api' | ||
}; | ||
connectApp.use( rest.rester( options ) ); | ||
Default _context_ is the empty string. | ||
## Discovery services | ||
@@ -211,3 +258,4 @@ [connect-rest](https://github.com/imrefazekas/connect-rest) provides a built-in service: discover. Via a simple get request, it allows you - by specifying a version - to discover the plublished REST apis matching the given version. | ||
That parameter debriefs the client what structure the functionN expects to receive. To activate this feature, first you have to add a new attribute to the options object: | ||
That parameter debriefs the client what structure the functionN expects to receive. | ||
To activate this feature, first you have to add a new attribute to the options object: | ||
@@ -363,3 +411,3 @@ var options = { | ||
## Server - extracted from the tests | ||
## Usage | ||
@@ -374,4 +422,8 @@ var connect = require('connect'); | ||
var options = { | ||
'apiKeys': [ '849b7648-14b8-4154-9ef2-8d1dc4c2b7e9' ], | ||
'discoverPath': 'discover' | ||
apiKeys: [ '849b7648-14b8-4154-9ef2-8d1dc4c2b7e9' ], | ||
discoverPath: 'discover', | ||
protoPath: 'proto', | ||
logger: 'connect-rest', | ||
logLevel: 'debug', | ||
context: '/api' | ||
}; | ||
@@ -388,6 +440,4 @@ connectApp.use( rest.rester( options ) ); | ||
# Installation | ||
[Back to Feature list](#features) | ||
$ npm install connect-rest | ||
## License | ||
@@ -426,2 +476,3 @@ | ||
- 0.0.30: minor fixes, refined documentation | ||
- 0.0.28.29: a case when mandatory parameter follows optional(s) has been fixed | ||
@@ -428,0 +479,0 @@ - 0.0.26-27: async request fix |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52495
493