Socket
Book a DemoInstallSign in
Socket

mali-ajv

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mali-ajv

Input validation for Mali.js gRPC microservices

latest
Source
npmnpm
Version
0.4.0
Version published
Weekly downloads
1
-87.5%
Maintainers
1
Weekly downloads
 
Created
Source

Ajv validation for Mali.js gRPC microservices

This package adds opinionated Ajv input validation support for Mali.js gRPC microservices.

Install

npm i --save mali-ajv

Setup

import Mali from 'mali'
import { addSchemas } from 'mali-ajv'
import * as accounts from './endpoints/accounts.schema.js'
import * as memberships from './endpoints/memberships.schema.js'

const app = new Mali()
app.use(addSchemas(app, { accounts, memberships }))
app.addService(file, 'Memberships', {})
app.addService(file, 'Accounts', {})
app.use('Accounts', { findOne: (ctx) => (ctx.res = 'hello world' ) })

Usage

Example request:

{
  "identity_id": "45670d4a-1185-4e5a-bd3",
  "name": ""
}

Throws the following error:

{
  "error": "9 FAILED_PRECONDITION: data.identity_id should match format \"uuid\""
}

Keywords

ajv

FAQs

Package last updated on 12 Nov 2021

Did you know?

Socket

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