Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reekoheek/node-bono-norm
https://github.com/reekoheek/node-bono-norm
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/reekoheek/node-bono-norm
- Owner: reekoheek
- License: mit
- Created: 2017-01-24T11:05:04.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-23T20:47:58.000Z (almost 2 years ago)
- Last Synced: 2024-04-25T00:03:09.471Z (8 months ago)
- Language: JavaScript
- Size: 886 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-xinix - bono-norm - Bono Norm Middleware and Bundle - [reekoheek](https://github.com/reekoheek) (Grouping / Node)
README
# bono-norm
## Install
```sh
npm i bono-norm
```## Usage
```js
// ...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
```js
// ...app.bundle('/user', new NormBundle({ schema: 'user', hiddenFields: ['password'] }));
// ...
```### Nested bundles
```js
// ...const userBundle = new NormBundle({ schema: 'user' };
userBundle.bundle('/{userId}/task', new NormBundle({ schema: 'task', filterBy: { userId: 'id' } }));app.bundle('/user', userBundle);
// ...
```