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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@croco/events-core

v0.0.2

Published

도메인 이벤트 기반 아키텍처를 위한 핵심 추상화 라이브러리입니다.

Readme

@croco/events-core

도메인 이벤트 기반 아키텍처를 위한 핵심 추상화 라이브러리입니다.

설치

pnpm add @croco/events-core

API

DomainEvent

도메인 이벤트의 기본 추상 클래스입니다.

import { DomainEvent } from '@croco/events-core';

class UserCreatedEvent extends DomainEvent {
  constructor(public readonly userId: string) {
    super();
  }
}

AggregateRoot

도메인 이벤트를 발행할 수 있는 Aggregate Root 추상 클래스입니다.

import { AggregateRoot, DomainEvent } from '@croco/events-core';

class User extends AggregateRoot {
  create(id: string) {
    this.addDomainEvent(new UserCreatedEvent(id));
  }
}

const user = new User();
user.create('user-123');

const events = user.getDomainEvents();
user.clearDomainEvents();

EventHandler

이벤트를 처리하는 핸들러 인터페이스와 데코레이터입니다.

import { EventHandler, RegisterEventHandler, DomainEvent } from '@croco/events-core';

@RegisterEventHandler(UserCreatedEvent)
class UserCreatedHandler implements EventHandler<UserCreatedEvent> {
  async handle(event: UserCreatedEvent): Promise<void> {
    console.log(`User created: ${event.userId}`);
  }
}

EventBus

이벤트를 발행하고 구독하는 버스 인터페이스입니다.

interface EventBus {
  publish(event: DomainEvent): Promise<void>;
  subscribe(subscription: EventSubscription): void;
  unsubscribe(subscription: EventSubscription): void;
  clear(): void;
}

EventBusConfig

EventBus 싱글톤 설정 및 핸들러 등록을 관리합니다.

import { EventBusConfig } from '@croco/events-core';
import { InMemoryEventBus } from '@croco/events-inmemory';

const config = EventBusConfig.getInstance();
config.setEventBus(new InMemoryEventBus());

await config.start({ handlers: [UserCreatedHandler] });

EventPublisher

설정된 EventBus를 통해 이벤트를 발행하는 헬퍼 클래스입니다.

import { EventPublisher } from '@croco/events-core';

const publisher = new EventPublisher();

await publisher.publish(new UserCreatedEvent('user-123'));
await publisher.publishMany([event1, event2]);

전체 예제

import 'reflect-metadata';
import {
  DomainEvent,
  AggregateRoot,
  EventHandler,
  RegisterEventHandler,
  EventBusConfig,
  EventPublisher,
} from '@croco/events-core';
import { InMemoryEventBus } from '@croco/events-inmemory';

class OrderPlacedEvent extends DomainEvent {
  constructor(
    public readonly orderId: string,
    public readonly amount: number
  ) {
    super();
  }
}

@RegisterEventHandler(OrderPlacedEvent)
class OrderPlacedHandler implements EventHandler<OrderPlacedEvent> {
  async handle(event: OrderPlacedEvent): Promise<void> {
    console.log(`Order ${event.orderId} placed for $${event.amount}`);
  }
}

const config = EventBusConfig.getInstance();
config.setEventBus(new InMemoryEventBus());
await config.start({ handlers: [OrderPlacedHandler] });

const publisher = new EventPublisher();
await publisher.publish(new OrderPlacedEvent('order-1', 100));