Huge News!Announcing our $40M Series B led by Abstract Ventures.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 0.3.1-4 to 0.3.1-5

2

package.json
{
"name": "baucis",
"version": "0.3.1-4",
"version": "0.3.1-5",
"main": "index.js",

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

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

baucis v0.3.1-4
baucis v0.3.1-5
===============

@@ -55,65 +55,2 @@

Use plain old Connect/Express middleware, including pre-existing modules like `passport`. For example, set the `all` option to add middleware to be called before all the model's API routes.
baucis.rest({
singular: 'vegetable',
all: function (request, response, next) {
if (request.isAuthenticated()) return next();
return response.send(401);
}
});
Or, set some middleware for specific HTTP verbs or disable verbs completely:
baucis.rest({
singular: 'vegetable',
get: [middleware1, middleware2],
post: middleware3,
del: false,
put: false
});
`baucis.rest` returns an instance of the controller created to handle the schema's API routes.
var subcontroller = baucis.rest({
singular: 'bar',
basePath: '/:fooId/bars'
publish: false, // don't add API routes automatically
restrict: function (query, request) {
// Only retrieve bars that are children of the given foo
query.where('parent', request.params.fooId);
}
});
var controller = baucis.rest({
singular: 'foo',
configure: function (controller) {
// Embed the subcontroller at /foos/:fooId/bars
controller.use(subcontroller);
// Embed arbitrary middleware at /foos/qux
controller.use('/qux', function (request, response, next) {
// Do something cool…
next();
});
}
});
Controllers are Express apps, so do whatever you want with them.
var controller = baucis.rest({
singular: 'robot',
configure: function (controller) {
// Add middleware before all other rotues in the controller
controller.use(express.cookieParser());
}
});
// Add middleware after default controller routes
controller.use(function () { ... });
controller.set('some option name', 'value');
controller.listen(3000);
Baucis uses the power of Express, without getting in its way. It's meant to be a way to organize your REST API's Express middleware.
Also note that Mongoose middleware will be executed as usual.

@@ -213,2 +150,80 @@

`bacuis.rest`
-------------
Use plain old Connect/Express middleware, including pre-existing modules like `passport`. For example, set the `all` option to add middleware to be called before all the model's API routes.
baucis.rest({
singular: 'vegetable',
all: function (request, response, next) {
if (request.isAuthenticated()) return next();
return response.send(401);
}
});
Or, set some middleware for specific HTTP verbs or disable verbs completely:
baucis.rest({
singular: 'vegetable',
get: [middleware1, middleware2],
post: middleware3,
del: false,
put: false
});
RESTful Headers
---------------
* `Accept: application/json` is set for all responses.
* The `Allow` header is set automatically, correctly removing HTTP verbs when
those verbs have been disabled with e.g. `put: false`.
* The `Location` HTTP header is set for PUT and POST responses.
* If `relations: true` is passed to `baucis.rest`, HTTP link headers will be set for all responses.
Controllers
-----------
`baucis.rest` returns an instance of the controller created to handle the schema's API routes.
var subcontroller = baucis.rest({
singular: 'bar',
basePath: '/:fooId/bars'
publish: false, // don't add API routes automatically
restrict: function (query, request) {
// Only retrieve bars that are children of the given foo
query.where('parent', request.params.fooId);
}
});
var controller = baucis.rest({
singular: 'foo',
configure: function (controller) {
// Embed the subcontroller at /foos/:fooId/bars
controller.use(subcontroller);
// Embed arbitrary middleware at /foos/qux
controller.use('/qux', function (request, response, next) {
// Do something cool…
next();
});
}
});
Controllers are Express apps, so do whatever you want with them.
var controller = baucis.rest({
singular: 'robot',
configure: function (controller) {
// Add middleware before all other rotues in the controller
controller.use(express.cookieParser());
}
});
// Add middleware after default controller routes
controller.use(function () { ... });
controller.set('some option name', 'value');
controller.listen(3000);
Baucis uses the power of Express, without getting in its way. It's meant to be a way to organize your REST API's Express middleware.
Contact Info

@@ -215,0 +230,0 @@ ------------

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc