From e0ebfd5e586c8abc4c4827a09ccbc26ef11a88c3 Mon Sep 17 00:00:00 2001 From: Rafael Almeida Date: Sat, 22 Nov 2014 20:31:39 +1300 Subject: [PATCH 1/3] add build control to the grunt template --- app/templates/Gruntfile.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/templates/Gruntfile.js b/app/templates/Gruntfile.js index 6755db958..3e2730130 100644 --- a/app/templates/Gruntfile.js +++ b/app/templates/Gruntfile.js @@ -17,7 +17,21 @@ module.exports = function (grunt) { cdnify: 'grunt-google-cdn', protractor: 'grunt-protractor-runner', buildcontrol: 'grunt-build-control', + istanbul_check_coverage: 'grunt-mocha-istanbul', + buildcontrol: 'grunt-build-control' + }); + + // Load grunt tasks automatically, when needed + require('jit-grunt')(grunt, { + express: 'grunt-express-server', + useminPrepare: 'grunt-usemin', + ngtemplates: 'grunt-angular-templates', + cdnify: 'grunt-google-cdn', + protractor: 'grunt-protractor-runner', + injector: 'grunt-asset-injector', + buildcontrol: 'grunt-build-control', istanbul_check_coverage: 'grunt-mocha-istanbul' + buildcontrol: 'grunt-build-control' }); // Time how long tasks take. Can help when optimizing build times From 1058726a32c9f628832ba3b5e1f704b77ee76b31 Mon Sep 17 00:00:00 2001 From: Rafael Almeida Date: Thu, 18 Dec 2014 12:29:39 +1300 Subject: [PATCH 2/3] fix (API Templates) remove the use of deprecated express methods --- .../server/api/thing/thing.controller(models).js | 8 ++++---- app/templates/server/api/user(auth)/user.controller.js | 6 +++--- endpoint/templates/name.controller.js | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/templates/server/api/thing/thing.controller(models).js b/app/templates/server/api/thing/thing.controller(models).js index a14fbd4b3..c7874b515 100644 --- a/app/templates/server/api/thing/thing.controller(models).js +++ b/app/templates/server/api/thing/thing.controller(models).js @@ -17,7 +17,7 @@ var Thing = sqldb.Thing;<% } %> function handleError(res, statusCode) { statusCode = statusCode || 500; return function(err) { - res.send(statusCode, err); + res.status(statusCode).send(err); }; } @@ -25,7 +25,7 @@ function responseWithResult(res, statusCode) { statusCode = statusCode || 200; return function(entity) { if (entity) { - return res.json(statusCode, entity); + return res.status(statusCode).json(entity); } }; } @@ -33,7 +33,7 @@ function responseWithResult(res, statusCode) { function handleEntityNotFound(res) { return function(entity) { if (!entity) { - res.send(404); + res.status(404).end(); return null; } return entity; @@ -58,7 +58,7 @@ function removeEntity(res) { <% if (filters.mongooseModels) { %>return entity.removeAsync()<% } if (filters.sequelizeModels) { %>return entity.destroy()<% } %> .then(function() { - return res.send(204); + return res.status(204).end(); }); } }; diff --git a/app/templates/server/api/user(auth)/user.controller.js b/app/templates/server/api/user(auth)/user.controller.js index 21b22ec08..43ae6ef73 100644 --- a/app/templates/server/api/user(auth)/user.controller.js +++ b/app/templates/server/api/user(auth)/user.controller.js @@ -11,21 +11,21 @@ var jwt = require('jsonwebtoken'); var validationError = function(res, statusCode) { statusCode = statusCode || 422; return function(err) { - res.json(statusCode, err); + return res.status(statusCode).json(err); }; }; function handleError(res, statusCode) { statusCode = statusCode || 500; return function(err) { - res.send(statusCode, err); + res.status(statusCode).send(err); }; } function respondWith(res, statusCode) { statusCode = statusCode || 200; return function() { - res.send(statusCode); + res.status(statusCode).end(); }; } diff --git a/endpoint/templates/name.controller.js b/endpoint/templates/name.controller.js index 9cdfb0fb0..90f955b0f 100644 --- a/endpoint/templates/name.controller.js +++ b/endpoint/templates/name.controller.js @@ -6,7 +6,7 @@ var <%= classedName %> = require('./<%= name %>.model'); function handleError(res, statusCode) { statusCode = statusCode || 500; return function(err) { - res.send(statusCode, err); + res.status(statusCode).send(err); }; } @@ -14,7 +14,7 @@ function responseWithResult(res, statusCode) { statusCode = statusCode || 200; return function(entity) { if (entity) { - return res.json(statusCode, entity); + return res.status(statusCode).json(entity); } }; } @@ -22,7 +22,7 @@ function responseWithResult(res, statusCode) { function handleEntityNotFound(res) { return function(entity) { if (!entity) { - res.send(404); + res.status(404).end(); return null; } return entity; @@ -44,7 +44,7 @@ function removeEntity(res) { if (entity) { return entity.removeAsync() .then(function() { - return res.send(204); + return res.status(204).end(); }); } }; From 20684c34650ca5e92ebc5cf0c83fdfafb8690ea0 Mon Sep 17 00:00:00 2001 From: Rafael Almeida Date: Thu, 18 Dec 2014 12:32:12 +1300 Subject: [PATCH 3/3] chore (Gruntfile.js) revert improper merge --- app/templates/Gruntfile.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/app/templates/Gruntfile.js b/app/templates/Gruntfile.js index 3e2730130..6755db958 100644 --- a/app/templates/Gruntfile.js +++ b/app/templates/Gruntfile.js @@ -17,21 +17,7 @@ module.exports = function (grunt) { cdnify: 'grunt-google-cdn', protractor: 'grunt-protractor-runner', buildcontrol: 'grunt-build-control', - istanbul_check_coverage: 'grunt-mocha-istanbul', - buildcontrol: 'grunt-build-control' - }); - - // Load grunt tasks automatically, when needed - require('jit-grunt')(grunt, { - express: 'grunt-express-server', - useminPrepare: 'grunt-usemin', - ngtemplates: 'grunt-angular-templates', - cdnify: 'grunt-google-cdn', - protractor: 'grunt-protractor-runner', - injector: 'grunt-asset-injector', - buildcontrol: 'grunt-build-control', istanbul_check_coverage: 'grunt-mocha-istanbul' - buildcontrol: 'grunt-build-control' }); // Time how long tasks take. Can help when optimizing build times