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 🙏

© 2024 – Pkg Stats / Ryan Hefner

wbrick

v0.0.18

Published

WBrick is a plugin-based system framework designed for Node.js web applications. It allows developers to build and manage application features in a modular way, providing flexible plugin loading, route management, event handling, and database interaction.

Downloads

6

Readme

WBrick

WBrick is a plugin-based system framework designed for Node.js Web applications. It allows developers to build and manage application features in a modular way, providing flexible plugin loading, route management, event handling, and database interaction capabilities.

Features

  • Plugin Architecture: Easily add, remove, and update the functional modules of the application.
  • Route Management: Plugins can independently register and manage their own routes.
  • Event-Driven: Supports the publication and subscription of events, promoting communication and collaboration between plugins.
  • Database Integration: Provides encapsulated database operations, supporting data isolation and secure data access.
  • Flexibility and Extensibility: Simple API and flexible design, suitable for a variety of application needs.

Installation

Install WBrick using npm:

npm install wbrick

Quick Start

Here is a basic example of how to use WBrick in your Node.js application.

First, create a plugin:

// /plugins/YourPlugin/index.js
const Router = require('koa-router');
module.exports = class Plugin {

    constructor(dependencies) {
        this.dependencies = dependencies;
        this.router = new Router();
    }

    initialize() {
        this.setupRoutes();
        // Use this.registerRoutes to register routes
        this.dependencies.routerInterface.registerRoutes(this.router);
        // Use this.mongooseWrapper.createModel to create models
    }

    setupRoutes() {
        this.router.get('/', async ctx => {
            console.log("plugin.path", ctx.path);
            ctx.body = 'Response from Plugin A';
        });
        // Other routes...
    }
};

Then, load and initialize the plugin in your application:

// /app.js
const Koa = require('koa');
const { PluginLoader } = require('wbrick');

const pluginLoader = new PluginLoader();
pluginLoader.initialize().then(() => {
    const app = new Koa();
    app.use(pluginLoader.getRouteMiddleware());
    app.listen(3000, () => {
        console.log('Server running on http://localhost:3000');
    });
});

Core Plugin Modules

The following are the core modules injected in the plugin constructor constructor(dependencies). The dependencies object interface is defined as follows:

export interface PluginDependencies {
    routerInterface?: RouteInterface;   // Router Interface Module, exposes router registration methods, allowing each plugin to have its own routes.
    eventInterface?: EventInterface;    // Event Loop Communication Module, implements inter-plugin event communication through event publishing, subscribing, and unsubscribing. The interface is as follows:
    apiInterface?: ApiInterface;        // Interface Communication Module, enables plugin API registration and invocation, facilitating communication between plugins.
    mongoInterface?: MongoInterface;    // Data access functionality for the MongoDB component, providing MongoDB database management capabilities.
    redisInterface?: RedisInterface;    // Redis caching component, offering caching read and write functionality.
    loggerInterface?: LoggerInterface;  // Log manager, a unified log manager that allows plugins to record their own logs.
    hookInterface?: HookInterface;      // Hook manager, providing plug-in direct hook function registration and triggering
}

For specific interface definitions, please refer to the source code. Documentation to follow.

Features to be Potentially Implemented [In Progress...]

  1. Configuration Manager: For managing and accessing settings in configuration files. Plugins may need to read or modify configurations, and the configuration manager can provide a unified interface for safely handling these operations.

  2. Task Scheduler: If the application involves scheduled tasks or background jobs, the task scheduler can manage the execution of these tasks. Plugins can register their own scheduled tasks, and the scheduler is responsible for executing them according to the schedule.

  3. Permissions and Security Management: If the system involves user permissions or security-related features, a security management service can be provided to handle authentication, authorization, encryption, access control, etc.

  4. Internationalization and Localization: For applications supporting multiple languages, provide internationalization (i18n) services to help plugins display content according to users' language preferences.

  5. Notification and Messaging Services: For sending messages or notifications between plugins or with users, which can be an internal message queue or integrated with external notification systems (such as email, SMS, etc.).

  6. Data Caching: A caching service can be provided for plugins to cache data, reducing requests to the database or external services.

  7. UI/UX Component Library: Offering a set of shared UI components to help maintain interface consistency and reduce development costs.

  8. Plugin Dependency Management: Managing the dependencies between plugins, ensuring that dependent plugins are correctly loaded.

  9. Health Checks and Monitoring: Monitoring the health of plugins and providing real-time information on system status.

Documentation

For more detailed documentation and API reference, please see Documentation Link.

Example

Sample project address: Link

License

MIT © shitiandmw