New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

baucis

Package Overview
Dependencies
Maintainers
1
Versions
202
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baucis - npm Package Compare versions

Comparing version

to
0.9.4

7

CHANGES.md
Baucis Change Log
=================
v0.9.4
------
Fix an issue where remove middleware wasn't called. Special thanks to lukaszfiszer!
v0.9.3
------
Set X-Powered-By to baucis for controller routes
Set X-Powered-By to baucis for baucis routes

@@ -9,0 +14,0 @@ v0.9.2

@@ -17,2 +17,20 @@ // __Dependencies__

},
del: function (request, response, next) {
request.baucis.query.exec(function (error, documents) {
if (error) return next(error);
if (!documents) return response.send(404);
// Make it an array if it wasn't already
var tasks = [].concat(documents).map(function (doc) {
return doc.remove.bind(doc);
});
async.parallel(tasks, function (error, removed) {
if (error) return next(error);
request.baucis.documents = removed.length;
next();
});
});
},
count: function (request, response, next) {

@@ -19,0 +37,0 @@ var lastModifiedPath = request.baucis.controller.get('lastModified');

4

middleware/query.js

@@ -36,3 +36,3 @@ // __Module Definition__

var Model = request.baucis.controller.get('model');
request.baucis.query = Model.remove(request.baucis.controller.getFindByConditions(request));
request.baucis.query = Model.findOne(request.baucis.controller.getFindByConditions(request));
next();

@@ -62,3 +62,3 @@ }

var Model = request.baucis.controller.get('model');
request.baucis.query = Model.remove(request.baucis.conditions);
request.baucis.query = Model.find(request.baucis.conditions);
next();

@@ -65,0 +65,0 @@ }

@@ -233,4 +233,6 @@ // This is a Controller mixin for adding methods to manage middleware creation.

activate('query', 'head', middleware.exec.count);
// Execute the find or remove query for GET and DELETE.
activate('query', 'get del', middleware.exec.exec);
// Execute the find query for GET.
activate('query', 'get', middleware.exec.exec);
// Execute the remove query for DELETE.
activate('query', 'del', middleware.exec.del);
// Create the documents for a POST request.

@@ -237,0 +239,0 @@ activate('query', 'collection', 'post', middleware.exec.create);

@@ -5,3 +5,3 @@ {

"homepage": "https://github.com/wprl/baucis",
"version": "0.9.3",
"version": "0.9.4",
"main": "index.js",

@@ -8,0 +8,0 @@ "scripts": {

@@ -1,2 +0,2 @@

baucis v0.9.3
baucis v0.9.4
=============

@@ -3,0 +3,0 @@

@@ -37,2 +37,19 @@ var expect = require('expect.js');

});
it('should invoke "remove" middleware', function (done) {
var shitake = vegetables[3];
var options = {
url: 'http://localhost:8012/api/v1/vegetables/' + shitake._id,
json: true
};
fixtures.vegetable.removeCount = 0;
request.del(options, function (error, response, body) {
if (error) return done(error);
expect(fixtures.vegetable).to.have.property('removeCount', 1);
done();
});
});
});

@@ -24,2 +24,18 @@ var expect = require('expect.js');

});
it('should invoke "remove" middleware', function (done) {
var options = {
url: 'http://localhost:8012/api/v1/vegetables/',
json: true
};
fixtures.vegetable.removeCount = 0;
request.del(options, function (error, response, body) {
if (error) return done(error);
expect(fixtures.vegetable).to.have.property('removeCount', 8);
done();
});
});
});

@@ -29,3 +29,4 @@ // __Dependencies__

fixture.preCount = 0;
fixture.saveCount = 0;
fixture.removeCount = 0;

@@ -43,6 +44,11 @@ Vegetable.pre('save', function (next) {

Vegetable.pre('save', function (next) {
fixture.preCount += 1;
fixture.saveCount += 1;
next();
});
Vegetable.pre('remove', function (next) {
fixture.removeCount += 1;
next();
});
var Fungus = new Schema({ 'hyphenated-field-name': String });

@@ -49,0 +55,0 @@ var Mineral = new Schema({ color: String });

@@ -107,3 +107,3 @@ var expect = require('expect.js');

it('should fire pre save Mongoose middleware', function (done) {
fixtures.vegetable.preCount = 0;
fixtures.vegetable.saveCount = 0;

@@ -117,3 +117,3 @@ var options = {

expect(fixtures.vegetable.preCount).to.be(1);
expect(fixtures.vegetable.saveCount).to.be(1);
done();

@@ -120,0 +120,0 @@ });

@@ -84,3 +84,3 @@ var expect = require('expect.js');

it('should fire pre save Mongoose middleware', function (done) {
fixtures.vegetable.preCount = 0;
fixtures.vegetable.saveCount = 0;

@@ -95,3 +95,3 @@ var radicchio = vegetables[7];

expect(fixtures.vegetable.preCount).to.be(1);
expect(fixtures.vegetable.saveCount).to.be(1);
done();

@@ -98,0 +98,0 @@ });