mali-ajv
v0.4.0
Published
Input validation for Mali.js gRPC microservices
Downloads
12
Readme
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\""
}