File tree Expand file tree Collapse file tree 2 files changed +17
-16
lines changed Expand file tree Collapse file tree 2 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,21 @@ module.exports = function(sails) {
4949
5050 var hook ;
5151
52+ const patchRoute = { } ;
53+ /*
54+ * Patch method does not redirect to the update blueprint by default
55+ * (see https://github.com/balderdashy/sails/pull/2006 for more details)
56+ * We will need to manually redirect all PATCH method to the update blueprint.
57+ */
58+ patchRoute [ 'PATCH ' + sails . config . blueprints . prefix + '/:model/:id' ] = function ( req , res ) {
59+ let id = req . allParams ( ) [ 'id' ] ;
60+ let model = pluralize . singular ( req . param ( 'model' ) ) ;
61+
62+ req . options . controller = model ;
63+ req . options . model = model ;
64+ BlueprintController . update ( req , res ) ;
65+ } ;
66+
5267 /**
5368 * Expose blueprint hook definition
5469 */
@@ -63,21 +78,7 @@ module.exports = function(sails) {
6378 } ,
6479
6580 routes : {
66- after : {
67- /*
68- * Patch method does not redirect to the update blueprint by default
69- * (see https://github.com/balderdashy/sails/pull/2006 for more details)
70- * We will need to manually redirect all PATCH method to the update blueprint.
71- */
72- 'PATCH /:model/:id' : function ( req , res ) {
73- let id = req . allParams ( ) [ 'id' ] ;
74- let model = pluralize . singular ( req . param ( 'model' ) ) ;
75-
76- req . options . controller = model ;
77- req . options . model = model ;
78- BlueprintController . update ( req , res ) ;
79- }
80- }
81+ after : patchRoute
8182 } ,
8283
8384 /**
Original file line number Diff line number Diff line change 11{
22 "name" : " sails-json-api-blueprints" ,
3- "version" : " 0.7 .0" ,
3+ "version" : " 0.8 .0" ,
44 "description" : " Blueprints to turn a Sails.js API into a JSON API" ,
55 "main" : " index.js" ,
66 "scripts" : {
You can’t perform that action at this time.
0 commit comments