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

@tecsafe/event-sdk

v0.13.0

Published

This repo contains the Event SDK which provides, typed amqp clients for OFCP services.

Readme

Event SDK

This repo contains the Event SDK which provides, typed amqp clients for OFCP services.

Installation

TypeScript / JavaScript:

npm install @tecsafe/event-sdk

PHP:

composer require tecsafe/event-sdk

JsonSchema:

curl -O https://tecsafe.github.io/event-sdk/json-schema/latest.json

Usage

Visit https://tecsafe.github.io/event-sdk/ for a more detailed documentation.

There is also an php version of the documentation available at https://tecsafe.github.io/event-sdk/php.

Typescript / Sending

import { MqService } from '@tecsafe/event-sdk';

(async () => {
  const mqService = new MqService()
  console.log('Sending message')
  await mqService.publish("CUSTOMER_MERGE", {
    newCustomerId: '123',
    oldCustomerId: '456',
    salesChannel: '789',
    test: {foo: 'bar'}
  });
  await mqService.close();
})().then();

Typescript / Receiving

import { MqService, MqError } from '@tecsafe/event-sdk';

(async () => {
  const mqService = new MqService('amqp://localhost', 'test')
  await mqService.subscribe("CUSTOMER_MERGE", (msg) => {
    /** Do your processing here */
    return true;
  });
  await mqService.subscribe("CUSTOMER_DELETE", (msg) => {
    /** Do your processing here */
    return new MqError(false);
  });
  await mqService.startConsuming();
})().then();

NestJS

// app.module.ts
import { Logger, Module } from '@nestjs/common';
import { NestJsEventModule } from '@tecsafe/event-sdk/adapter/nestjs/dist/index';

@Module({
  imports: [
    NestJsEventModule.forRoot(
      'amqp://localhost', // connection string
      'test', // queue name (normally the service name)
      'general', // exchange name
      true, // requeue unhandled messages
      new Logger('MqService')
    ),
  ],
  providers: [],
})
export class AppModule {}
// app.service.ts
import { Injectable, OnModuleInit } from '@nestjs/common';
import { MqService, createMqListener } from '@tecsafe/event-sdk';

@Injectable()
export class AppService implements onModuleInit {
  constructor(private readonly mqService: MqService) {}

  onModuleInit() {
    this.mqService.subscribe('CUSTOMER_MERGE', this.handleCustomerMerge.bind(this));
  }

  readonly handleCustomerMerge = createMqListener('CUSTOMER_MERGE', (payload) => {
    console.log('Received CUSTOMER_MERGE event', payload);
  });

  async sendCustomerMergeEvent() {
    await this.mqService.publish('CUSTOMER_MERGE', {
      newCustomerId: '123',
      oldCustomerId: '456',
      salesChannel: '789',
      test: { foo: 'bar' },
    });
  }

  async sendCustomerDeleteEvent() {
    await this.mqService.publish('CUSTOMER_DELETE', {
      customer: '123',
      salesChannel: '789',
    });
  }
}

PHP / Sending

<?php
declare(strict_types=1);

require_once __DIR__ . '/vendor/autoload.php';

use Tecsafe\OFCP\Events\Models\MergeCustomerPayload;
use Tecsafe\OFCP\Events\Models\TestType;
use Tecsafe\OFCP\Events\MqService;

$service = new MqService();
$service->send_customer_merge(new MergeCustomerPayload(
  /** values... */
));
$service->closeConnection();

PHP / Receiving

<?php
declare(strict_types=1);

require_once __DIR__ . '/vendor/autoload.php';

use Tecsafe\OFCP\Events\Listeners\DeleteCustomerPayloadListener;
use Tecsafe\OFCP\Events\Models\DeleteCustomerPayload;
use Tecsafe\OFCP\Events\Models\MergeCustomerPayload;
use Tecsafe\OFCP\Events\MqService;
use Tecsafe\OFCP\Events\MqServiceError;

$service = new MqService('localhost', 5672, 'guest', 'guest', 'test');

// Either use a listener class
class CustomerDeleteListener implements DeleteCustomerPayloadListener
{
  public function on_event(DeleteCustomerPayload $payload): MqServiceError | bool
  {
    /** Do your processing here */
    return new MqServiceError(false);
  }
}

$service->subscribe_customer_delete(new CustomerDeleteListener());

// Or use a callback
$service->subscribe_customer_merge(function (MergeCustomerPayload $payload) {
  return true;
});

// Start consuming, this will block the script
$service->startConsuming();

Symfony Bundle

This SDK comes with a symfony bundle, that integrates into symfony messenger. For this purpose the bundle creates a new MessageBus-instance named ofcp_events. You have to use this new bus and dispatch a message with a special stamp called EventNameStamp. A custom messenger-middleware and serializer are responsible for hiding implementation details.

Install

  1. Register the bundle

    #   config/bundles.php 
       
    return [
        // ... other bundles
        Tecsafe\OFCP\Events\Symfony\Bundle\TecsafeOfcpEventsBundle::class => ['all' => true],
    ]
    
  2. Configure bundle with env vars

    MESSENGER_TRANSPORT_OFCP_DSN=amqp://rabbitmq:rabbitmq@rabbitmq:5672/%2f/ofcp
    MESSENGER_TRANSPORT_OFCP_EXCHANGE_NAME=your-own-exchange
    MESSENGER_TRANSPORT_OFCP_EXCHANGE_TYPE=topic
    MESSENGER_TRANSPORT_OFCP_QUEUE_NAME=your-own-queue

Usage

Dispatch message to ofcp event bus

<?php

declare(strict_types=1);

namespace App;

use Symfony\Component\Messenger\MessageBusInterface;
use Tecsafe\OFCP\Events\Models\CustomerCreatedEventPayload;
use Tecsafe\OFCP\Events\Symfony\Bundle\Messenger\EventNameStamp;
use Tecsafe\OFCP\Events\EventMap;

class YourService 
{
    public function __construct(
        /**
         * With autowiring, symfony will provide the ofcp_events-bus with this variable name.
         * Otherwise inject it manually.
         */
        private MessageBusInterface $ofcpEvents,
    ) {
        parent::__construct();
    }

    public function yourMethod()
    {
        $this->ofcpEvents->dispatch(new CustomerCreatedEventPayload('foo', 'bar'), [
            new EventNameStamp(EventMap::CUSTOMER_CREATED['name'])
        ]);
    }
}

Handle message from ofcp event bus

<?php

declare(strict_types=1);

namespace App\Messenger\MessageHandler;

use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Tecsafe\OFCP\Events\Models\CustomerCreatedEventPayload;
use Tecsafe\OFCP\Events\Symfony\Bundle\Messenger\Constants;

#[AsMessageHandler(
    bus: Constants::MESSENGER_OFCP_EVENTS_BUS_NAME,
)]
class CustomerCreatedHandler
{
    public function __invoke(CustomerCreatedEventPayload $payload): void
    {
        // Your own logic
    }
}

Run worker

$ bin/console messenger:consume ofcp_events

JsonSchema

See https://json-schema.org/ for more information on how to use JsonSchema.