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

@api-buddy/plugin-core

v3.0.0

Published

Core plugin system for API Buddy

Readme

API Buddy Plugin Core

The plugin system allows extending API Buddy's functionality through a well-defined API. Plugins can hook into various lifecycle events and extend the core functionality.

Features

  • Lifecycle Hooks: Plugins can subscribe to various lifecycle events
  • Type Safety: Full TypeScript support with type definitions
  • Plugin Discovery: Automatic loading from node_modules or custom directories
  • Schema Extensions: Extend and modify the schema
  • Type Generation: Customize TypeScript type generation
  • Database Integration: Add support for different databases
  • Flexible Loading: Support for both ESM and CommonJS modules

Installation

# Install the core plugin package
pnpm add @api-buddy/plugin-core

Usage

Basic Example

import { PluginManager, PluginHook } from '@api-buddy/plugin-core';

// Create a plugin manager
const pluginManager = new PluginManager({
  debug: true,
  cwd: process.cwd(), // Optional: specify the working directory
});

// Load a single plugin
await pluginManager.loadPlugin({
  name: 'my-plugin',
  version: '1.0.0',
  hooks: {
    [PluginHook.BeforeSchemaLoad]: [
      async (context, schema) => {
        console.log('Modifying schema...');
        // Modify schema here
        return schema;
      }
    ]
  }
});

// Or load multiple plugins from a directory
await pluginManager.loadPlugins('plugins'); // Load from ./plugins directory

// Or load from node_modules
await pluginManager.loadPlugins('node_modules', {
  pattern: /^@my-org\/api-buddy-/ // Optional: filter by package name pattern
});

// Call a hook
await pluginManager.callHook(PluginHook.BeforeSchemaLoad, mySchema);

// Clean up
await pluginManager.destroy();

Available Hooks

| Hook | Description | Parameters | |------|-------------|------------| | BeforeSchemaLoad | Before schema is loaded | (context, schema) => Schema | | AfterSchemaLoad | After schema is loaded | (context, schema) => void | | BeforeCodegen | Before code generation | (context) => void | | AfterCodegen | After code generation | (context) => void | | BeforeTypegen | Before type generation | (context, schema) => void | | AfterTypegen | After type generation | (context, schema) => void | | BeforeMigrate | Before database migration | (context) => void | | AfterMigrate | After database migration | (context) => void |

Creating a Plugin

Create a plugin by implementing the Plugin interface:

import { Plugin, PluginHook } from '@api-buddy/plugins';

const myPlugin: Plugin = {
  name: 'my-plugin',
  version: '1.0.0',
  description: 'My awesome plugin',
  
  hooks: {
    [PluginHook.BeforeSchemaLoad]: [
      async (context, schema) => {
        // Modify schema here
        return schema;
      }
    ]
  },
  
  async initialize(context) {
    console.log('Plugin initialized');
  },
  
  async destroy() {
    console.log('Plugin destroyed');
  }
};

export default myPlugin;

Plugin Extensions

Plugins can provide additional functionality through extensions:

Schema Extensions

const schemaPlugin: Plugin & SchemaPluginExtension = {
  name: 'schema-plugin',
  version: '1.0.0',
  
  extendSchema(schema) {
    // Add custom fields/types to the schema
    return schema;
  },
  
  validateSchema(schema) {
    // Validate the schema
    return []; // Return array of error messages
  }
};

Type Generation Extensions

const typegenPlugin: Plugin & TypegenPluginExtension = {
  name: 'typegen-plugin',
  version: '1.0.0',
  
  getTypeMappings() {
    return {
      CustomType: 'string',
    };
  },
  
  generateTypes(schema) {
    // Generate custom type definitions
    return '// Custom types';
  }
};

License

MIT