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.10.2

22

CHANGES.md
Baucis Change Log
=================
v0.10.2
-------
Send 204 when no content.
v0.10.1
-------
Improvements to optimistic locking. Adds the 'locking' controller option. When set to true, this option enables automatic version increments and strict version checking. When enabled, `__v` must always be sent with updates, and the baucis query must always have the `__v` key selected.
Improvements to optimistic locking. Adds the 'locking' controller option. When set to true, this option enables *automatic* version increments and strict version checking. When enabled, `__v` must always be sent with updates, and the baucis query must always have the `__v` key selected.

@@ -14,18 +18,4 @@ If this option is not enabled, no extra lock checking or version incrementing is performed outside what is normally done by Mongoose.

-------
Send `409 Conflict` when there are document version conflicts. This is useful for optimistic locking.
Deprecated
Mongoose only updates `__v` for certain array operations by default. To update for every save (optimistic locking), add this Mongoose middleware to the schema:
schema.pre('save', funciton (next) {
this.increment();
next();
});
By default, document version is only checked for conflict when the versionKey is sent with the PUT request, otherwise no version checking is done. To force version checking for all PUT requests:
var controller = baucis.rest({
singular: 'tea',
'always check version': true
});
v0.9.4

@@ -32,0 +22,0 @@ ------

@@ -8,3 +8,3 @@ // __Dependencies__

// __Private Module Members__
var controllers = [];
var controllersForVersion = {};

@@ -52,36 +52,40 @@ // Figure out the basePath for Swagger API definition

// Activate Swagger resource listing if the option is enabled
if (app.get('swagger') === true) {
app.get('/api-docs', function (request, response, next) {
response.set('X-Powered-By', 'Baucis');
response.json(app.generateResourceListing({ version: options.version, basePath: getBase(request, 1) }));
});
}
// Mount all published controllers to the baucis app
controllers.forEach(function (controller) {
var route = url.resolve('/', controller.get('plural'));
// Add a route for the controller's Swagger API definition
if (app.get('swagger')) {
app.get('/api-docs' + route, function (request, response, next) {
Object.keys(controllersForVersion).forEach(function (version) {
// Activate Swagger resource listing if the option is enabled
if (app.get('swagger') === true) {
app.get('/api-docs', function (request, response, next) {
var listingInfo = { version: version, basePath: getBase(request, 1) };
var resourceListing = app.generateResourceListing(listingInfo);
response.set('X-Powered-By', 'Baucis');
response.json({
apiVersion: options.version,
swaggerVersion: '1.1',
basePath: getBase(request, 2),
resourcePath: route,
apis: controller.swagger.apis,
models: controller.swagger.models
});
response.json(resourceListing);
});
}
// Initialize and mount the controller
controller.initialize();
app.use(route, controller);
// Mount all published controllers to the baucis app
controllers.forEach(function (controller) {
var route = url.resolve('/', controller.get('plural'));
// Add a route for the controller's Swagger API definition
if (app.get('swagger')) {
app.get('/api-docs' + route, function (request, response, next) {
response.set('X-Powered-By', 'Baucis');
response.json({
apiVersion: version,
swaggerVersion: '1.1',
basePath: getBase(request, 2),
resourcePath: route,
apis: controller.swagger.apis,
models: controller.swagger.models
});
});
}
// Initialize and mount the controller
controller.initialize();
app.use(route, controller);
});
});
// Empty the controllers array to prepare for creating more APIs
controllers = [];
controllersForVersion = {};

@@ -94,9 +98,13 @@ return app;

var controller = Controller(options);
var version = controller.get('version');
controller.generateSwaggerDefinition();
// Publish unless told not to
if (options.publish !== false) controllers.push(controller);
// Don't publish it automatically if private.
if (options.publish === false) return controller;
if (!controllersForVersion[version]) controllersForVersion = [];
controllersForVersion[version].push(controller);
return controller;
};

@@ -43,9 +43,7 @@ // __Dependencies__

if (!documents) return response.send(404);
if (request.baucis.noBody) return response.send();
// Send 204 No Content if no body.
if (request.baucis.noBody) return response.send(204);
// If it's a document count (e.g. the result of a DELETE), send it back and
// short-circuit.
if (typeof documents === 'number') return response.json(documents);
// If count mode is set, send the length, or send 1 for single document

@@ -57,6 +55,4 @@ if (request.baucis.count) {

}
// If it's not a POST, send now because Location shouldn't be set.
if (request.method !== 'POST') return response.json(documents);
// Ensure there is a trailing slash on basePath for proper function of

@@ -66,3 +62,2 @@ // url.resolve, otherwise the model's plural will be missing in the location

if(!basePath.match(/\/$/)) basePath += '/';
// Otherwise, set the location and send JSON document(s). Don't set location if documents

@@ -69,0 +64,0 @@ // don't have IDs for whatever reason e.g. custom middleware.

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

"homepage": "https://github.com/wprl/baucis",
"version": "0.10.1",
"version": "0.10.2",
"main": "index.js",

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

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

baucis v0.10.1
baucis v0.10.2
==============

@@ -10,3 +10,3 @@

Baucis now includes over 120 Mocha.js tests.
Baucis is tested with over 120 Mocha.js tests.

@@ -13,0 +13,0 @@ <a href="https://www.gittip.com/wprl/">Donations via gittip.com are appreciated.</a>