Socket
Socket
Sign inDemoInstall

@salsita/koa-joi-middleware

Package Overview
Dependencies
2
Maintainers
6
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @salsita/koa-joi-middleware

[![NPM version](https://img.shields.io/npm/v/@salsita/koa-joi-middleware.svg)](https://www.npmjs.com/package/@salsita/koa-joi-middleware) ![Downloads](https://img.shields.io/npm/dm/@salsita/koa-joi-middleware.svg?style=flat) ![Licence](https://img.shields


Version published
Weekly downloads
1
Maintainers
6
Created
Weekly downloads
 

Readme

Source

@salsita/koa-joi-middleware

NPM version Downloads Licence Dependency Status devDependency Status

Middleware used on routes to validate input.

Example:

const joi = require("@hapi/joi");
const Router = require("koa-router");
const joiMiddleware = require("@salsita/koa-joi-middleware");

const router = new Router();

const paramsSchema = joi.object().keys({
  id: joi.number().integer().positive().required()
}).required();
const bodySchema = joi.object().keys({
  name: joi.string().max(1024).required(),
  email: joi.string().email().max(1024).required()
}).required();

router.patch(
  '/:id',
  joiMiddleware([
    { get: ctx => ctx.params, schema: paramsSchema },
    { get: ctx => ctx.request.body, schema: bodySchema },
  ],
  async ctx => { /* perform stuff */ }
);

FAQs

Last updated on 06 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc