Merge branch 'release/2.8.5' into production

This commit is contained in:
Miroslav Bajtoš 2014-12-12 08:57:05 +01:00
commit 581c4230ba
6 changed files with 58 additions and 19 deletions

View File

@ -1,3 +1,15 @@
2014-12-12, Version 2.8.5
=========================
* fix jshint errors (Clark Wang)
* test if cb exists (Clark Wang)
* fix nested remoting function throwing error will crash app (Clark Wang)
* Fix bcrypt issues for browserify (Raymond Feng)
2014-12-08, Version 2.8.4 2014-12-08, Version 2.8.4
========================= =========================
@ -1228,14 +1240,6 @@
* 2.0.0-beta1 (Ritchie Martori) * 2.0.0-beta1 (Ritchie Martori)
* Bump version (Raymond Feng)
* Add postgresql to the keywords (Raymond Feng)
* updated package.json with SOAP and framework keywords (altsang)
* updated package.json with keywords and updated description (Raymond Feng)
* Make app.datasources unique per app instance (Miroslav Bajtoš) * Make app.datasources unique per app instance (Miroslav Bajtoš)
* Add RC version (Ritchie Martori) * Add RC version (Ritchie Martori)
@ -1301,11 +1305,6 @@
* Add Change model (Ritchie Martori) * Add Change model (Ritchie Martori)
2014-05-27, Version 1.8.4
=========================
2014-05-27, Version 1.8.5 2014-05-27, Version 1.8.5
========================= =========================
@ -1317,8 +1316,14 @@
* updated package.json with keywords and updated description (Raymond Feng) * updated package.json with keywords and updated description (Raymond Feng)
2014-05-27, Version 1.8.4
=========================
* Add more keywords (Raymond Feng) * Add more keywords (Raymond Feng)
* Bump version (Raymond Feng)
* app: flatten model config (Miroslav Bajtoš) * app: flatten model config (Miroslav Bajtoš)
* Fix the test for mocha 1.19.0 (Raymond Feng) * Fix the test for mocha 1.19.0 (Raymond Feng)

View File

@ -70,7 +70,7 @@ module.exports = function(grunt) {
'dist/loopback.js': ['index.js'], 'dist/loopback.js': ['index.js'],
}, },
options: { options: {
ignore: ['nodemailer', 'passport'], ignore: ['nodemailer', 'passport', 'bcrypt'],
standalone: 'loopback' standalone: 'loopback'
} }
} }
@ -174,7 +174,8 @@ module.exports = function(grunt) {
'passport', 'passport',
'passport-local', 'passport-local',
'superagent', 'superagent',
'supertest' 'supertest',
'bcrypt'
], ],
// transform: ['coffeeify'], // transform: ['coffeeify'],
// debug: true, // debug: true,

View File

@ -11,6 +11,10 @@ var bcrypt;
try { try {
// Try the native module first // Try the native module first
bcrypt = require('bcrypt'); bcrypt = require('bcrypt');
// Browserify returns an empty object
if (bcrypt && typeof bcrypt.compare !== 'function') {
bcrypt = require('bcryptjs');
}
} catch (err) { } catch (err) {
// Fall back to pure JS impl // Fall back to pure JS impl
bcrypt = require('bcryptjs'); bcrypt = require('bcryptjs');

View File

@ -674,7 +674,11 @@ Model.nestRemoting = function(relationName, options, cb) {
this[getterName](fkId, function(err, inst) { this[getterName](fkId, function(err, inst) {
if (err && cb) return cb(err); if (err && cb) return cb(err);
if (inst instanceof relation.modelTo) { if (inst instanceof relation.modelTo) {
nestedFn.apply(inst, args); try {
nestedFn.apply(inst, args);
} catch (err) {
if (cb) return cb(err);
}
} else if (cb) { } else if (cb) {
cb(err, null); cb(err, null);
} }
@ -688,7 +692,11 @@ Model.nestRemoting = function(relationName, options, cb) {
this[getterName](function(err, inst) { this[getterName](function(err, inst) {
if (err && cb) return cb(err); if (err && cb) return cb(err);
if (inst instanceof relation.modelTo) { if (inst instanceof relation.modelTo) {
nestedFn.apply(inst, args); try {
nestedFn.apply(inst, args);
} catch (err) {
if (cb) return cb(err);
}
} else if (cb) { } else if (cb) {
cb(err, null); cb(err, null);
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "loopback", "name": "loopback",
"version": "2.8.4", "version": "2.8.5",
"description": "LoopBack: Open Source Framework for Node.js", "description": "LoopBack: Open Source Framework for Node.js",
"homepage": "http://loopback.io", "homepage": "http://loopback.io",
"keywords": [ "keywords": [
@ -94,7 +94,8 @@
"express": "./lib/browser-express.js", "express": "./lib/browser-express.js",
"./lib/server-app.js": "./lib/browser-express.js", "./lib/server-app.js": "./lib/browser-express.js",
"connect": false, "connect": false,
"nodemailer": false "nodemailer": false,
"bcrypt": false
}, },
"license": { "license": {
"name": "Dual MIT/StrongLoop", "name": "Dual MIT/StrongLoop",

View File

@ -1168,6 +1168,13 @@ describe('relations - integration', function() {
Page.hasMany(Note); Page.hasMany(Note);
Image.belongsTo(Book); Image.belongsTo(Book);
// fake a remote method that match the filter in Model.nestRemoting()
Page.prototype['__throw__errors'] = function() {
throw new Error('This should not crash the app');
};
Page.remoteMethod('__throw__errors', { isStatic: false, http: { path: '/throws', verb: 'get' } });
Book.nestRemoting('pages'); Book.nestRemoting('pages');
Image.nestRemoting('book'); Image.nestRemoting('book');
@ -1305,6 +1312,19 @@ describe('relations - integration', function() {
}); });
}); });
}); });
it('should catch error if nested function throws', function(done) {
var test = this;
this.get('/api/books/' + test.book.id + '/pages/' + this.page.id + '/throws')
.end(function(err, res) {
expect(res.body).to.be.an('object');
expect(res.body.error).to.be.an('object');
expect(res.body.error.name).to.equal('Error');
expect(res.body.error.status).to.equal(500);
expect(res.body.error.message).to.equal('This should not crash the app');
done();
});
});
}); });
}); });