Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oakfang/oompa-ensure
An Oompa middleware to ensure payload keys
https://github.com/oakfang/oompa-ensure
Last synced: 6 days ago
JSON representation
An Oompa middleware to ensure payload keys
- Host: GitHub
- URL: https://github.com/oakfang/oompa-ensure
- Owner: oakfang
- License: mit
- Created: 2016-07-10T18:09:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-07-10T21:19:14.000Z (over 8 years ago)
- Last Synced: 2024-11-09T18:19:12.773Z (2 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# oompa-ensure
An Oompa middleware to ensure payload keys## Usage
```js
const Oompa = require('oompa');
const tokenize = require('oompa-token');
const ensure = require('oompa-ensure');
const schema = require('./schema');const SECRET = 'foobar';
const server = new Oompa(schema);
server.use(ensure('GET_INFO', 'token'));
server.use(ensure('SET_INFO', 'token'));
server.use(tokenize(SECRET, 'LOGIN'));server.listen(9000);
```## Why?
To make sure a certain task has all of its required payload properties.### `require('oompa-ensure')(type:String, ...keys:[String])`
- **type** is the task type you wish to ensure the presence if certain keys for.
- **keys** is the list of keys you wish to ensure are in the task's payload.### Side Effects
The request does not change in any way, but if an ensured key is missing, the request is reject early.