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

gdmb

v1.3.5

Published

通用领域模型基座,提供领域模型设计开发通用基座能力。依赖 `tsyringe` 提供依赖注入能力。

Readme

项目介绍

通用领域模型基座,提供领域模型设计开发通用基座能力。依赖 tsyringe 提供依赖注入能力。

安装

npm i gdmb --save

依赖

以下依赖需要在项目中引入

  • tsyringe:轻量级依赖注入容器
  • reflect-metadata: 反射元数据

修改 tsconfig.json 配置,开放元数据与反射支持

  "emitDecoratorMetadata": true,
  "experimentalDecorators": true

用例

注册领域、领域服务、领域实体

/** DomainOne.ts */
import { GDMB, Domain, DomainService, DomainEntity } from 'gdmb';

/** 值对象接口 */
export interface IVOOne {
  text: string
}

/** 实例化gdmb实例对象,全局单例 */
const gdmb = new GDMB();

/** 领域一 */
class DomainOne extends Domain {
  constructor() {
    super();
    // 注册服务域
    this.registerService(ServiceOne);
    // 注册实体域
    this.registerEntity(EntityOne);
    // 注册值对象
    this.registerValueObject<IVOOne>({
      token: 'IVOOne',
      factoryType: 'containerCache',
      resolveFactory() {
        return { text: 'this is value object' };
      }
    });
    // 更多使用方法参考类型定义
  }
}

/** 服务一 */
class ServiceOne extends DomainService {}

/** 实体一 */
class EntityOne extends DomainEntity {}

/** 注册领域 */
gdmb.registerDomain(DomainOne);

获取领域相关实例

import { GDMB, Domain } from 'gdmb';

/** 实例化gdmb实例对象,全局单例 */
const gdmb = new GDMB();

// 获取领域对象
const domainOne = gdmb.domains(DomainOne.name);
/** 或者 */
const domainOne = gdmb.domains(DomainOne);

// 获取服务对象
const serviceOne = domainOne.services(ServiceOne.name);
/** 或者 */
const serviceOne = domainOne.services(ServiceOne);

// 获取实体对象
const entityOne = domainOne.entities(EntityOne.name);
/** 或者 */
const entityOne = domainOne.entities(EntityOne);

// 获取值对象
const voOne = domainOne.vos('IVOOne');