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

brick-engine

v0.12.1

Published

basic engine

Downloads

97

Readme

brick-engine

基于nodejs的应用程序引擎包.通过插件和模块机制,赋予应用对框架或模块的良好适配和扩展性.

summary

Install

npm install --save brick-engine

Usage

使用bin/brick-engine来启动应用.


# 默认为当前执行路径
npx brick-engine

# 指定应用路径(应用包路径/应用入口文件路径)
npx brick-engine {path 1} {...} {path N}

Entry Point

引擎需要使用应用入口来启动应用程序

const { defineApplication,defineModule } = require('brick-engine');
// 模块
const {OtherModule} = require('xxx_module_path');
// 插件
const {PluginModule} = require('xxx_plugin_path');
// 依赖注入对象
const {InjectModule} = require('xxx_inject_path');

class App{
}

// 定义应用入口
defineApplication(exports,App);

// 定义应用子模块
defineModule(App,OtherModule);
// 定义应用插件模块
defineModule(App,PluginModule);
// 定义应用注入对象
defineModule(App,InjectModule);

Engine Module

应用在brick-engine中加载处理的模块.例如:引擎插件,依赖注入模块,应用子模块(模块集合)等


const { defineModule } = require('brick-engine');

// 模块
const {OtherModule} = require('xxx_module_path');
// 插件
const {PluginModule} = require('xxx_plugin_path');
// 依赖注入对象
const {InjectModule} = require('xxx_inject_path');

class SubModule {
  constructor() {
    console.log('sub_module:new');
  }
}

exports.SubModule = SubModule;

// 定义应用子模块
defineModule(SubModule,OtherModule);
// 定义应用插件模块
defineModule(SubModule,PluginModule);
// 定义应用注入对象
defineModule(SubModule,InjectModule);

Engine Plugin

使用Engine Module来实现特定功能的扩展模块.插件模块本身也可以作为Engine Module提供给其他插件模块使用.


const { definePlugin } = require('brick-engine');

// 依赖注入对象
const {InjectModule} = require('xxx_inject_path');

class Plugin {
  match(module) {
    // 插件筛选匹配模块代码.(返回: true/false)
    return true;
  }
  async use(module) {
     // 插件使用模块功能代码
  }
}


exports.Plugin = Plugin;

// 定义插件,指定构建插件所需要的依赖模块
definePlugin(SubPlugin, { deps: [{ id: InjectModule }] });

Engine Inject

应用使用的依赖注入对象,也可以作为Engine Module提供给其他插件模块使用.


const { defineProviderFactory } = require('brick-engine');

// 依赖注入对象
const {OtherInjectModule} = require('xxx_inject_path');

class InjectModule {
    constructor(otherInjectModule) {
       // 初始化注入对象代码
    }
}

exports.InjectModule = InjectModule;

// 定义依赖对象,指定构建对象所需要的依赖模块
defineProviderFactory(InjectModule, { deps: [{ id: OtherInjectModule }] });

Documentations

使用jsdoc生成注释文档

git clone https://github.com/kiba-zhao/brick-engine.git
cd brick-engine
npm install
npm run docs
open docs/index.html

License

MIT