npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@asyncapi/keeper

v0.5.0

Published

AsyncAPI message payload validation library that validates messages against JSON Schema (Draft-07)

Readme

@asyncapi/keeper

AsyncAPI message payload validation library that validates messages against JSON Schema (Draft-07).

Installation

npm install @asyncapi/keeper

API

await compileSchemas(schemas)

Parameters

| Parameter | Type | Description | Required | |-----------|--------------------|-----------------------------------------------------------------------------|----------| | schemas | Array<Object> | Array of JSON Schema Draft-07 objects representing valid message structures | Yes |

Returns

Promise<Array<function>> — Array of compiled schema validator functions.

await compileSchemasByOperationId(asyncapiFilepath, operationId)

Parameters

| Parameter | Type | Description | Required | |---------------------|--------------|---------------------------------------------------------------------------------------------|----------| | asyncapiFilepath | string | Path to the AsyncAPI document file. | Yes | | operationId | string | The ID of the operation to extract message schemas from. | Yes |

Returns

Promise<Array<function>> — Array of compiled schema validator functions for the operation's messages.

validateMessage(compiledSchemas, message)

Parameters

| Parameter | Type | Description | Required | |------------------|--------------------|-----------------------------------------------------------------------------|----------| | compiledSchemas| Array<function> | Array of compiled schema validator functions | Yes | | message | any | The message payload to validate (any non-null value) | Yes |

Returns

{ isValid: boolean, validationErrors?: Array<object> } — Object containing validation result and errors if invalid.

removeCompiledSchemas()

Returns

void — Unregisters all currently registered schemas from the validator.

Usage

Basic Schema Compilation and Validation

import { compileSchemas, validateMessage, removeCompiledSchemas } from '@asyncapi/keeper';

// Example schemas (JSON Schema Draft-07 objects)
const schemas = [
  {
    type: 'object',
    properties: {
      content: { type: 'string' },
      timestamp: { type: 'string', format: 'date-time' }
    },
    required: ['content', 'timestamp'],
    additionalProperties: false
  },
  {
    type: 'object',
    properties: {
      content: { type: 'string' }
    },
    required: ['content'],
    additionalProperties: false
  }
];

// Compile schemas
const compiledSchemas = await compileSchemas(schemas);

// Validate messages
const message1 = { content: 'Hello', timestamp: '2024-05-01T12:00:00Z' };
const result1 = validateMessage(compiledSchemas, message1);
console.log('Valid:', result1.isValid); // true
console.log('Errors:', result1.validationErrors); // undefined

const message2 = { content: 42 }; // Invalid: content should be string
const result2 = validateMessage(compiledSchemas, message2);
console.log('Valid:', result2.isValid); // false
console.log('Errors:', result2.validationErrors); // Array of validation errors

// Clean up
removeCompiledSchemas();

Operation-Specific Validation

import { compileSchemasByOperationId, validateMessage, removeCompiledSchemas } from '@asyncapi/keeper';
import path from 'path';

const asyncapiFilepath = path.resolve(__dirname, './asyncapi.yaml'); // Path to your AsyncAPI document
const operationId = 'sendHelloMessage'; // The operationId to validate against

// Compile schemas for specific operation
const compiledSchemas = await compileSchemasByOperationId(asyncapiFilepath, operationId);

// Validate message against operation schemas
const message = { content: 'Hello from operation' };
const result = validateMessage(compiledSchemas, message);
console.log('Valid for operation:', result.isValid); // true or false

// Clean up
removeCompiledSchemas();