From c26221186d92b5285bf588f1fc3b0f74207c3e7e Mon Sep 17 00:00:00 2001 From: aniknafs Date: Mon, 17 Oct 2016 13:36:12 -0700 Subject: [PATCH 1/2] fix (endpoint:controller): fix findOneAndUpdate syntax findOneAndUpdate return modified document now instead of original fixes #2284 --- templates/endpoint/basename.controller.js | 2 +- templates/endpoint/basename.integration.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/endpoint/basename.controller.js b/templates/endpoint/basename.controller.js index 63279b423..a9b5fa74c 100644 --- a/templates/endpoint/basename.controller.js +++ b/templates/endpoint/basename.controller.js @@ -101,7 +101,7 @@ export function upsert(req, res) { delete req.body._id; } <%_ if(filters.mongooseModels) { -%> - return <%= classedName %>.findOneAndUpdate({_id: req.params.id}, req.body, {upsert: true, setDefaultsOnInsert: true, runValidators: true}).exec()<% } %> + return <%= classedName %>.findOneAndUpdate({_id: req.params.id}, req.body, {new: true, upsert: true, setDefaultsOnInsert: true, runValidators: true}).exec()<% } %> <%_ if(filters.sequelizeModels) { -%> return <%= classedName %>.upsert(req.body, { where: { diff --git a/templates/endpoint/basename.integration.js b/templates/endpoint/basename.integration.js index 9f5db9738..fafd3f483 100644 --- a/templates/endpoint/basename.integration.js +++ b/templates/endpoint/basename.integration.js @@ -105,9 +105,9 @@ describe('<%= classedName %> API:', function() { updated<%= classedName %> = {}; }); - it('should respond with the original <%= cameledName %>', function() { - <%= expect() %>updated<%= classedName %>.name<%= to() %>.equal('New <%= classedName %>'); - <%= expect() %>updated<%= classedName %>.info<%= to() %>.equal('This is the brand new <%= cameledName %>!!!'); + it('should respond with the updated <%= cameledName %>', function() { + <%= expect() %>updated<%= classedName %>.name<%= to() %>.equal('Updated <%= classedName %>'); + <%= expect() %>updated<%= classedName %>.info<%= to() %>.equal('This is the updated <%= cameledName %>!!!'); }); it('should respond with the updated <%= cameledName %> on a subsequent GET', function(done) { From 1bd29d5ef91b563ffcb8251aa086b05eba62e2f0 Mon Sep 17 00:00:00 2001 From: aniknafs Date: Tue, 18 Oct 2016 17:19:23 -0700 Subject: [PATCH 2/2] docs (generators): Heroku generator run manually Remove 'yo angular-fullstack:heroku' (not working) Update docs to reflect manual setup Fixes: #1966, #1950 --- docs/generators/heroku.md | 45 ++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/docs/generators/heroku.md b/docs/generators/heroku.md index 8024dd55b..cf822a04f 100644 --- a/docs/generators/heroku.md +++ b/docs/generators/heroku.md @@ -1,21 +1,47 @@ ### Heroku -Deploying to heroku only takes a few steps. +#### Setup +You need a [Heroku](www.heroku.com) account and have the [Heroku Toolbelt](https://devcenter.heroku.com/articles/getting-started-with-nodejs#set-up) installed. +Create an app on Heroku and give it a name (e.g. myapp) : ``` -yo angular-fullstack:heroku +heroku apps:create myapp ``` +You can also use Heroku dashboard to create an app. -To work with your new heroku app using the command line, you will need to run any `heroku` commands from the `dist` folder. +If you're using mongoDB you will need to add a database to your app (e.g. [mlab](https://mlab.com/) or [compose](https://www.compose.com/mongodb)): +Here we use mlab: +``` +heroku addons:create mongolab +``` +Now, build your app by running: +``` +gulp build +``` +This creates a folder called `dist`. -If you're using mongoDB you will need to add a database to your app: +Now go to `dist` and set it up as a git repository: +``` +git init +``` +Add Heroku's app as your `dist` folder's remote repository: ``` -heroku addons:create mongolab +heroku git:remote -a myapp ``` -Note: if you get an `Error: No valid replicaset instance servers found` you need to modify moongose connection options in config/environment/production.js as follows: +It is time to push your local repository to Heroku. From your app's root run: +``` +gulp buildcontrol:heroku +``` + +Your app should be live now. To view your app run: +``` +heroku open +``` + +Note on MongoDB setup: if you get an `Error: No valid replicaset instance servers found` you need to modify moongose connection options in config/environment/production.js as follows: ``` options: { db: { @@ -25,10 +51,8 @@ options: { } } ``` -One of the odd things about the Node driver is that the default timeout for replica set connections is only 1 second, so make sure you're setting it to something more like 30s like in this example. - -Your app should now be live. To view it run `heroku open`. +One of the odd things about the Node driver is that the default timeout for replica set connections is only 1 second, so make sure you're setting it to something more like 30s like in this example. > > If you're using any oAuth strategies, you must set environment variables for your selected oAuth. For example, if we're using **Facebook** oAuth we would do this : @@ -47,8 +71,6 @@ Your app should now be live. To view it run `heroku open`. > ``` > -To make your deployment process easier consider using [grunt-build-control](https://github.com/robwierzbowski/grunt-build-control). - #### Pushing Updates ``` @@ -56,7 +78,6 @@ gulp build ``` Commit and push the resulting build, located in your dist folder: - ``` gulp buildcontrol:heroku ```