Comparing version 0.1.0-5 to 0.1.0-6
## 0.1.0 | ||
### prerelease 6 | ||
Fixed case on hyperResource and hyperResponse requires in index.js. | ||
### prerelease 5 | ||
@@ -65,2 +68,2 @@ Add `_resource` and `_action` fields to resources so that consumers can determine "friendly" names by which each resource was produced. | ||
### 0.0.1 | ||
Initial check-in | ||
Initial check-in |
{ | ||
"name": "hyped", | ||
"version": "0.1.0-5", | ||
"version": "0.1.0-6", | ||
"description": "Hypermedia response generation engine", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -14,8 +14,8 @@ var should = require( "should" ); // jshint ignore: line | ||
hyped = require( "../src/index.js" )( false, true ); | ||
autohost.init( { | ||
resources: "./spec/ah", | ||
noOptions: true, | ||
urlPrefix: "/test", | ||
urlStrategy: hyped.urlStrategy | ||
} ) // just roll with the defaults... | ||
autohost.init( { | ||
resources: "./spec/ah", | ||
noOptions: true, | ||
urlPrefix: "/test", | ||
urlStrategy: hyped.urlStrategy | ||
} ) // just roll with the defaults... | ||
.then( hyped.addResources ) | ||
@@ -40,3 +40,3 @@ .then( done ); | ||
contentType.should.equal( "application/json" ); | ||
body.should.eql( {"id":100,"title":"Test Board","lanes":[{"id":200,"title":"To Do","wip":0,"cards":[{"id":301,"title":"Card 1","description":"This is card 1"},{"id":302,"title":"Card 2","description":"This is card 2"},{"id":303,"title":"Card 3","description":"This is card 3"}]},{"id":201,"title":"Doing","wip":0,"cards":[{"id":304,"title":"Card 4","description":"This is card 4"}]},{"id":202,"title":"Done","wip":0,"cards":[{"id":305,"title":"Card 5","description":"This is card 5"},{"id":306,"title":"Card 6","description":"This is card 6"}]}]} ); | ||
body.should.eql( { "id": 100, "title": "Test Board", "lanes": [ { "id": 200, "title": "To Do", "wip": 0, "cards": [ { "id": 301, "title": "Card 1", "description": "This is card 1" }, { "id": 302, "title": "Card 2", "description": "This is card 2" }, { "id": 303, "title": "Card 3", "description": "This is card 3" } ] }, { "id": 201, "title": "Doing", "wip": 0, "cards": [ { "id": 304, "title": "Card 4", "description": "This is card 4" } ] }, { "id": 202, "title": "Done", "wip": 0, "cards": [ { "id": 305, "title": "Card 5", "description": "This is card 5" }, { "id": 306, "title": "Card 6", "description": "This is card 6" } ] } ] } ); | ||
} ); | ||
@@ -70,4 +70,4 @@ } ); | ||
_embedded: { | ||
lanes: [ | ||
{ | ||
lanes: [ | ||
{ | ||
id: 200, | ||
@@ -93,4 +93,4 @@ title: "To Do", | ||
_embedded: { | ||
cards: [ | ||
{ | ||
cards: [ | ||
{ | ||
id: 301, | ||
@@ -172,3 +172,3 @@ title: "Card 1", | ||
} | ||
} | ||
} | ||
] | ||
@@ -435,4 +435,4 @@ } | ||
_embedded: { | ||
lanes: [ | ||
{ | ||
lanes: [ | ||
{ | ||
id: 200, | ||
@@ -458,4 +458,4 @@ title: "To Do", | ||
_embedded: { | ||
cards: [ | ||
{ | ||
cards: [ | ||
{ | ||
id: 301, | ||
@@ -537,3 +537,3 @@ title: "Card 1", | ||
} | ||
} | ||
} | ||
] | ||
@@ -763,4 +763,4 @@ } | ||
_origin: { | ||
href: "/test/api/board/100/lane/201", | ||
method: "GET" | ||
href: "/test/api/board/100/lane/201", | ||
method: "GET" | ||
}, | ||
@@ -770,10 +770,10 @@ _resource: "lane", | ||
_links: { | ||
self: { | ||
href: "/test/api/board/100/lane/201", | ||
method: "GET" | ||
}, | ||
cards: { | ||
href: "/test/api/board/100/lane/201/card", | ||
method: "GET" | ||
} | ||
self: { | ||
href: "/test/api/board/100/lane/201", | ||
method: "GET" | ||
}, | ||
cards: { | ||
href: "/test/api/board/100/lane/201/card", | ||
method: "GET" | ||
} | ||
}, | ||
@@ -787,4 +787,4 @@ _embedded: { | ||
_origin: { | ||
href: "/test/api/card/304", | ||
method: "GET" | ||
href: "/test/api/card/304", | ||
method: "GET" | ||
}, | ||
@@ -794,15 +794,15 @@ _resource: "card", | ||
_links: { | ||
self: { | ||
href: "/test/api/card/304", | ||
method: "GET" | ||
}, | ||
move: { | ||
href: "/test/api/card/304/board/{boardId}/lane/{laneId}", | ||
method: "PUT", | ||
templated: true | ||
}, | ||
block: { | ||
href: "/test/api/card/304/block", | ||
method: "PUT" | ||
} | ||
self: { | ||
href: "/test/api/card/304", | ||
method: "GET" | ||
}, | ||
move: { | ||
href: "/test/api/card/304/board/{boardId}/lane/{laneId}", | ||
method: "PUT", | ||
templated: true | ||
}, | ||
block: { | ||
href: "/test/api/card/304/block", | ||
method: "PUT" | ||
} | ||
} | ||
@@ -828,6 +828,6 @@ } | ||
var expected = { | ||
var expected = { | ||
_origin: { href: "/test/api/board/100/card", method: "GET" }, | ||
cards: [ | ||
{ | ||
cards: [ | ||
{ | ||
id: 301, | ||
@@ -839,6 +839,6 @@ title: "Card 1", | ||
_action: "self", | ||
_links: { | ||
_links: { | ||
self: { href: "/test/api/card/301", method: "GET" }, | ||
move: { href: "/test/api/card/301/board/{boardId}/lane/{laneId}", method: "PUT", templated: true }, | ||
block: { href: "/test/api/card/301/block", method: "PUT" } | ||
block: { href: "/test/api/card/301/block", method: "PUT" } | ||
} | ||
@@ -853,6 +853,6 @@ }, | ||
_action: "self", | ||
_links: { | ||
_links: { | ||
self: { href: "/test/api/card/302", method: "GET" }, | ||
move: { href: "/test/api/card/302/board/{boardId}/lane/{laneId}", method: "PUT", templated: true }, | ||
block: { href: "/test/api/card/302/block", method: "PUT" } | ||
block: { href: "/test/api/card/302/block", method: "PUT" } | ||
} | ||
@@ -867,6 +867,6 @@ }, | ||
_action: "self", | ||
_links: { | ||
_links: { | ||
self: { href: "/test/api/card/303", method: "GET" }, | ||
move: { href: "/test/api/card/303/board/{boardId}/lane/{laneId}", method: "PUT", templated: true }, | ||
block: { href: "/test/api/card/303/block", method: "PUT" } | ||
block: { href: "/test/api/card/303/block", method: "PUT" } | ||
} | ||
@@ -894,7 +894,7 @@ }, | ||
_action: "self", | ||
_links: { | ||
_links: { | ||
self: { href: "/test/api/card/305", method: "GET" }, | ||
move: { href: "/test/api/card/305/board/{boardId}/lane/{laneId}", method: "PUT", templated: true }, | ||
block: { href: "/test/api/card/305/block", method: "PUT" } | ||
} | ||
block: { href: "/test/api/card/305/block", method: "PUT" } | ||
} | ||
}, | ||
@@ -909,8 +909,8 @@ { | ||
_links: { | ||
self: { href: "/test/api/card/306", method: "GET" }, | ||
move: { href: "/test/api/card/306/board/{boardId}/lane/{laneId}", method: "PUT", templated: true }, | ||
block: { href: "/test/api/card/306/block", method: "PUT" } | ||
} | ||
} | ||
] | ||
self: { href: "/test/api/card/306", method: "GET" }, | ||
move: { href: "/test/api/card/306/board/{boardId}/lane/{laneId}", method: "PUT", templated: true }, | ||
block: { href: "/test/api/card/306/block", method: "PUT" } | ||
} | ||
} | ||
] | ||
}; | ||
@@ -943,26 +943,4 @@ | ||
var expectedOptions = { | ||
_links: | ||
{ | ||
"_autohost:api": { href: "/test/api/_autohost", method: "GET" }, | ||
"_autohost:resources": { href: "/test/api/_autohost/resource", method: "GET" }, | ||
"_autohost:actions": { href: "/test/api/_autohost/action", method: "GET" }, | ||
"_autohost:connected-sockets": { href: "/test/api/_autohost/sockets", method: "GET" }, | ||
"_autohost:list-users": { href: "/test/api/_autohost/user", method: "GET" }, | ||
"_autohost:list-roles": { href: "/test/api/_autohost/role", method: "GET" }, | ||
"_autohost:list-user-roles": { href: "/test/api/_autohost/user/{user}/role", method: "GET", templated: true }, | ||
"_autohost:list-action-roles": { href: "/test/api/_autohost/action/{action}/role", method: "GET", templated: true }, | ||
"_autohost:add-action-roles": { href: "/test/api/_autohost/action/{action}/role", method: "PATCH", templated: true }, | ||
"_autohost:remove-action-roles": { href: "/test/api/_autohost/action/{action}/role", method: "DELETE", templated: true }, | ||
"_autohost:add-user-roles": { href: "/test/api/_autohost/user/{user}/role", method: "PATCH", templated: true }, | ||
"_autohost:remove-user-roles": { href: "/test/api/_autohost/user/{user}/role", method: "DELETE", templated: true }, | ||
"_autohost:add-role": { href: "/test/api/_autohost/role/{role}", method: "POST", templated: true }, | ||
"_autohost:remove-role": { href: "/test/api/_autohost/role/{role}", method: "DELETE", templated: true }, | ||
"_autohost:create-user": { href: "/test/api/_autohost/user/{userName}", method: "POST", templated: true }, | ||
"_autohost:change-password": { href: "/test/api/_autohost/user/{userName}", method: "PATCH", templated: true }, | ||
"_autohost:create-token": { href: "/test/api/_autohost/token", method: "POST" }, | ||
"_autohost:destroy-token": { href: "/test/api/_autohost/token/{token}", method: "DELETE", templated: true }, | ||
"_autohost:list-tokens": { href: "/test/api/_autohost/token/", method: "GET" }, | ||
"_autohost:enable-user": { href: "/test/api/_autohost/user/{userName}", method: "PUT", templated: true }, | ||
"_autohost:disable-user": { href: "/test/api/_autohost/user/{userName}", method: "DELETE", templated: true }, | ||
"_autohost:metrics": { href: "/test/api/_autohost/metrics", method: "GET" }, | ||
_links: | ||
{ | ||
"board:cards": { href: "/test/api/board/{id}/card", method: "GET", templated: true }, | ||
@@ -1018,3 +996,3 @@ "board:self": { href: "/test/api/board/{id}", method: "GET", templated: true }, | ||
describe( "when requesting board with no media type", function() { | ||
var expected = {"id":100,"title":"Test Board","description":"This is a board and stuff!","lanes":[{"id":200,"title":"To Do","wip":0,"cards":[{"id":301,"title":"Card 1","description":"This is card 1"},{"id":302,"title":"Card 2","description":"This is card 2"},{"id":303,"title":"Card 3","description":"This is card 3"}]},{"id":201,"title":"Doing","wip":0,"cards":[{"id":304,"title":"Card 4","description":"This is card 4"}]},{"id":202,"title":"Done","wip":0,"cards":[{"id":305,"title":"Card 5","description":"This is card 5"},{"id":306,"title":"Card 6","description":"This is card 6"}]}]}; | ||
var expected = { "id": 100, "title": "Test Board", "description": "This is a board and stuff!", "lanes": [ { "id": 200, "title": "To Do", "wip": 0, "cards": [ { "id": 301, "title": "Card 1", "description": "This is card 1" }, { "id": 302, "title": "Card 2", "description": "This is card 2" }, { "id": 303, "title": "Card 3", "description": "This is card 3" } ] }, { "id": 201, "title": "Doing", "wip": 0, "cards": [ { "id": 304, "title": "Card 4", "description": "This is card 4" } ] }, { "id": 202, "title": "Done", "wip": 0, "cards": [ { "id": 305, "title": "Card 5", "description": "This is card 5" }, { "id": 306, "title": "Card 6", "description": "This is card 6" } ] } ] }; | ||
var body, contentType; | ||
@@ -1040,2 +1018,2 @@ | ||
} ); | ||
} ); | ||
} ); |
var _ = require( "lodash" ); | ||
var HyperResponse = require( "./HyperResponse.js" ); | ||
var HyperResource = require( "./HyperResource.js" ); | ||
var HyperResponse = require( "./hyperResponse.js" ); | ||
var HyperResource = require( "./hyperResource.js" ); | ||
var jsonEngine = require( "./jsonEngine.js" ); | ||
@@ -20,3 +20,3 @@ var halEngine = require( "./halEngine.js" ); | ||
var getVersion = function( req ) { | ||
if( !maxVersion ) { | ||
if ( !maxVersion ) { | ||
maxVersion = getMaxVersion(); | ||
@@ -27,3 +27,3 @@ } | ||
var version = preferLatest ? maxVersion : 1; | ||
if( match && match.length > 0 ) { | ||
if ( match && match.length > 0 ) { | ||
version = parseInt( match[ 1 ] ); | ||
@@ -50,3 +50,3 @@ } | ||
function addEngine( engine, mediaType ) { // jshint ignore:line | ||
if( _.isArray( mediaType ) ) { | ||
if ( _.isArray( mediaType ) ) { | ||
_.each( mediaType, function( m ) { | ||
@@ -61,3 +61,3 @@ engines[ m ] = engine; | ||
function addMiddleware( host, apiPrefix ) { // jshint ignore:line | ||
if( host.use ) { | ||
if ( host.use ) { | ||
prefix = apiPrefix; | ||
@@ -80,3 +80,3 @@ host.use( apiPrefix, optionsMiddleware ); | ||
function addResources( resources ) { // jshint ignore:line | ||
if( _.isArray( resources ) ) { | ||
if ( _.isArray( resources ) ) { | ||
_.each( resources, function( resource ) { | ||
@@ -92,3 +92,3 @@ addResource( resource, resource.name ); | ||
var mediaType = req.headers.accept; | ||
if( !mediaType ) { | ||
if ( !mediaType ) { | ||
mediaType = "application/json"; | ||
@@ -106,6 +106,6 @@ } | ||
var version = 1; | ||
if( req ) { | ||
if ( req ) { | ||
version = getVersion( req ); | ||
} | ||
if( !hypermodels[ version ] ) { | ||
if ( !hypermodels[ version ] ) { | ||
hypermodels[ version ] = HyperResource.renderFn( resources, prefix, version ); // jshint ignore: line | ||
@@ -118,6 +118,6 @@ } | ||
var version = 1; | ||
if( req ) { | ||
if ( req ) { | ||
version = getVersion( req ); | ||
} | ||
if( !optionModels[ version ] ) { | ||
if ( !optionModels[ version ] ) { | ||
optionModels[ version ] = HyperResource.optionsFn( resources, prefix, version, excludeChildren )( engines ); | ||
@@ -130,6 +130,6 @@ } | ||
var version = 1; | ||
if( req ) { | ||
if ( req ) { | ||
version = getVersion( req ); | ||
} | ||
if( !fullOptionModels[ version ] ) { | ||
if ( !fullOptionModels[ version ] ) { | ||
fullOptionModels[ version ] = HyperResource.optionsFn( resources, prefix, version, false )( engines ); | ||
@@ -148,3 +148,3 @@ } | ||
function hyperMiddleware( req, res, next ) { // jshint ignore:line | ||
if( !req.extendHttp ) { | ||
if ( !req.extendHttp ) { | ||
req.extendHttp = {}; | ||
@@ -160,6 +160,6 @@ } | ||
function optionsMiddleware( req, res, next ) { // jshint ignore:line | ||
if( req.method === "OPTIONS" || req.method === "options" ) { | ||
if ( req.method === "OPTIONS" || req.method === "options" ) { | ||
var contentType = getContentType( req ); | ||
var engine = getEngine( contentType ); | ||
if( !engine ) { | ||
if ( !engine ) { | ||
contentType = "application/json"; | ||
@@ -181,3 +181,3 @@ engine = jsonEngine; | ||
function urlStrategy( resourceName, actionName, action, resourceList ) { // jshint ignore:line | ||
if( _.isEmpty( resources ) ) { | ||
if ( _.isEmpty( resources ) ) { | ||
resources = resourceList; | ||
@@ -191,3 +191,3 @@ } | ||
module.exports = function( resourceList, defaultToNewest, includeChildrenInOptions ) { | ||
if( resourceList === true || resourceList === false ) { | ||
if ( resourceList === true || resourceList === false ) { | ||
preferLatest = resourceList; | ||
@@ -203,2 +203,2 @@ excludeChildren = defaultToNewest === undefined ? true : !defaultToNewest; | ||
return wrapper; | ||
}; | ||
}; |
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
133836
3293