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

heirloom-core

v2.0.6

Published

Heirloom Core Module

Downloads

9

Readme

heirloom-core NPM version

NPM Downloads Node.js Version Build Status

  • koa^2.2.0(http://koajs.com/)

定义标准接口及泛型,以不变应万变。

将当前热门的一些框架或工具封装一层后,作为接口的实现类以依赖的方式安装集成到项目。以应对将来项目演进过程中,换用更优的选择时,能够平滑替换。

安装

npm install heirloom-core --save

相关项目

遵循规约重于配置的思想所实现的一些插件,尽量减少业务以外不必要的代码量。

heirloom-static-plugin

用于打包构建客户端静态资源,具体请移步查看详情

heirloom-api-plugin

用于包装后端RPC或其他各种服务,提供统一接口,具体请移步查看详情

heirloom-security-plugin

TODO: coming soon...

用于保护请求资源已经接口鉴权的插件,目前有以下两种实现:

  • 传统账号/密码登录

  • JSON Web Token

  • OAuth2

工程目录

server/
├── src/--------------------------------------项目源码
│   ├── engines/---------------------------------引擎
│   │   ├── KoaEngine.js----------------------------基于Engine接口,使用Koa框架的实现
│   │   └── index.js--------------------------------入口文件
│   ├── NormalServer.js--------------------------基于Server接口的一种常规实现
│   └── index.js---------------------------------入口文件
├── lib/--------------------------------------通过babel将src目录下的源码构建到该目录
└── index.js----------------------------------入口文件

基本概念

Engine

Node第三方服务框架:Express/Koa等的封装,其接口定义如下(目前以Express/Koa等的接口为蓝本):

interface Engine {
    name: string;
    version: string;

    use(any: any):void;
    listen(port: number, callback: ()=>void):void;
    on(event: string, callback: (error: ?Error | ?any) => void):void;
}

Plugin

基于服务器框架的中间件或一些业务功能模块的封装,其接口定义如下:

interface Plugin {
    name: string;
    version: string;

    apply(): Array<any> | any | Generator<*> | (req: any, res: any, next: Function)=>void;
}

Server

服务器,接口定义如下:

interface Server {
    port: number;
    engine: Engine;

    apply(plugin: Plugin):void;
    start():void;
}