New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

supervizor

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

supervizor - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

8

CHANGELOG.md
# Changelog
## [v2.1.0](https://github.com/ruiquelhas/supervizor/tree/v2.1.0) (2017-11-11)
[Full Changelog](https://github.com/ruiquelhas/supervizor/compare/v2.0.0...v2.1.0)
**Implemented enhancements:**
- Support async validators [\#11](https://github.com/ruiquelhas/supervizor/issues/11)
- Add support for asynchronous validators [\#12](https://github.com/ruiquelhas/supervizor/pull/12) ([ruiquelhas](https://github.com/ruiquelhas))
## [v2.0.0](https://github.com/ruiquelhas/supervizor/tree/v2.0.0) (2017-11-07)

@@ -4,0 +12,0 @@ [Full Changelog](https://github.com/ruiquelhas/supervizor/compare/v1.0.6...v2.0.0)

4

lib/index.js

@@ -9,3 +9,3 @@ 'use strict';

return function (request, h) {
return async function (request, h) {

@@ -20,3 +20,3 @@ if (request.method !== 'post') {

try {
const payload = options.validator(request.payload, opts);
const payload = await options.validator(request.payload, opts);

@@ -23,0 +23,0 @@ if (payload) {

{
"name": "supervizor",
"version": "2.0.0",
"version": "2.1.0",
"description": "Server-level request payload validation for hapi",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -10,3 +10,4 @@ # supervizor

- [Usage](#usage)
- [Example](#example)
- [Synchronous validation](#synchronous-validation)
- [Asynchronous validation](#asynchronous-validation)

@@ -26,3 +27,3 @@ ## Installation

### Example
### Synchronous validation

@@ -64,2 +65,42 @@ ```js

### Asynchronous validation
```js
const Hapi = require('hapi');
const Supervizor = require('supervizor');
const plugin = {
plugin: Supervizor,
options: {
validator: async (payload, options) => {
// In this example, an asychronous validation function is called.
try {
await validate(payload, options);
// Be nice to yourself and allow further validation.
return payload;
}
catch (err) {
// Be nice to everyone and provide details about the issue.
// protip: https://github.com/hapijs/joi/blob/v13.0.1/API.md#errors
const error = new Error('invalid payload');
error.details = [{ path: ['valid'] }];
throw error;
}
}
}
};
try {
const server = new Hapi.Server();
await server.register(plugin);
await server.start();
}
catch (err) {
throw err;
}
```
[coveralls-img]: https://img.shields.io/coveralls/ruiquelhas/supervizor.svg?style=flat-square

@@ -66,0 +107,0 @@ [coveralls-url]: https://coveralls.io/github/ruiquelhas/supervizor

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