bono-norm
v2.1.0
Published
Node + Bono + Norm get along together
Downloads
20
Readme
bono-norm
Install
npm i bono-norm
Usage
// ...
const Bundle = require('bono');
const normMiddleware = require('bono-norm');
const NormBundle = require('bono-norm/bundle');
const config = {
connections: [
{
name: 'default',
adapter: 'disk',
},
],
};
// create app bundle
const app = new Bundle();
// add middleware to use bono manager from bundle
app.use(normMiddleware(config));
// add json middleware to return data from bundle as json body
app.use(require('bono/middlewares/json')());
// add bundle with collection schema name
app.bundle('/user', new NormBundle({ schema: 'user' }));
// ...
Hide fields
// ...
app.bundle('/user', new NormBundle({ schema: 'user', hiddenFields: ['password'] }));
// ...
Nested bundles
// ...
const userBundle = new NormBundle({ schema: 'user' };
userBundle.bundle('/{userId}/task', new NormBundle({ schema: 'task', filterBy: { userId: 'id' } }));
app.bundle('/user', userBundle);
// ...