Comparing version
Baucis Change Log | ||
================= | ||
v0.10.3 | ||
------- | ||
Don't change status to 204 for HEAD requests. | ||
v0.10.2 | ||
@@ -5,0 +9,0 @@ ------- |
68
index.js
@@ -8,3 +8,3 @@ // __Dependencies__ | ||
// __Private Module Members__ | ||
var controllersForVersion = {}; | ||
var controllers = []; | ||
@@ -52,40 +52,36 @@ // Figure out the basePath for Swagger API definition | ||
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); | ||
// 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) { | ||
response.set('X-Powered-By', 'Baucis'); | ||
response.json(resourceListing); | ||
response.json({ | ||
apiVersion: options.version, | ||
swaggerVersion: '1.1', | ||
basePath: getBase(request, 2), | ||
resourcePath: route, | ||
apis: controller.swagger.apis, | ||
models: controller.swagger.models | ||
}); | ||
}); | ||
} | ||
// 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); | ||
}); | ||
// Initialize and mount the controller | ||
controller.initialize(); | ||
app.use(route, controller); | ||
}); | ||
// Empty the controllers array to prepare for creating more APIs | ||
controllersForVersion = {}; | ||
controllers = []; | ||
@@ -98,13 +94,9 @@ return app; | ||
var controller = Controller(options); | ||
var version = controller.get('version'); | ||
controller.generateSwaggerDefinition(); | ||
// Don't publish it automatically if private. | ||
if (options.publish === false) return controller; | ||
// Publish unless told not to | ||
if (options.publish !== false) controllers.push(controller); | ||
if (!controllersForVersion[version]) controllersForVersion = []; | ||
controllersForVersion[version].push(controller); | ||
return controller; | ||
}; |
@@ -44,3 +44,6 @@ // __Dependencies__ | ||
// Send 204 No Content if no body. | ||
if (request.baucis.noBody) return response.send(204); | ||
if (request.baucis.noBody) { | ||
if (request.method === 'HEAD') return response.send(); | ||
else return response.send(204); | ||
} | ||
// If it's a document count (e.g. the result of a DELETE), send it back and | ||
@@ -47,0 +50,0 @@ // short-circuit. |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://github.com/wprl/baucis", | ||
"version": "0.10.2", | ||
"version": "0.10.3", | ||
"main": "index.js", | ||
@@ -8,0 +8,0 @@ "scripts": { |
@@ -1,2 +0,2 @@ | ||
baucis v0.10.2 | ||
baucis v0.10.3 | ||
============== | ||
@@ -3,0 +3,0 @@ |
620269
-0.04%3737
-0.11%