🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis
Socket
Book a DemoInstallSign in
Socket

@eggjs/tegg-eventbus-plugin

Package Overview
Dependencies
Maintainers
8
Versions
188
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eggjs/tegg-eventbus-plugin

tegg event plugin

latest
Source
npmnpm
Version
3.64.4
Version published
Weekly downloads
889
8.15%
Maintainers
8
Weekly downloads
 
Created
Source

@eggjs/tegg-eventbus-plugin

Usage

// plugin.js
export.eventbusModule = {
  enable: true,
  package: '@eggjs/tegg-eventbus-plugin',
};

Unittest

// test/fixtures/apps/event-app/app/event-module/HelloService
@ContextProto({
  accessLevel: AccessLevel.PUBLIC,
})
export class HelloService {
  @Inject()
  private readonly eventBus: EventBus;

  hello() {
    this.eventBus.emit('hello', '01');
  }
}

// test/fixtures/apps/event-app/app/event-module/HelloLogger
@Event('helloEgg')
export class HelloLogger {
  handle(msg: string) {
    console.log('hello, ', msg);
  }
}


// test/event.test.ts
import assert from 'assert';
import path from 'path';
import mm from 'egg-mock';
import { HelloService } from './fixtures/apps/event-app/app/event-module/HelloService';
import { HelloLogger } from './fixtures/apps/event-app/app/event-module/HelloLogger';

describe('test/eventbus.test.ts', () => {
  let app;
  let ctx;

  afterEach(async () => {
    await app.destroyModuleContext(ctx);
    mm.restore();
  });

  before(async () => {
    app = mm.app();
    await app.ready();
  });

  after(() => {
    return app.close();
  });

  it('msg should work', async () => {
    ctx = await app.mockModuleContext();
    const helloService = await ctx.getEggObject(HelloService);
    let msg: string | undefined;
    // helloLogger is in child context, should mock the prototype
    mm(HelloLogger.prototype, 'handle', m => {
      msg = m;
    });
    const eventWaiter = await app.getEventWaiter();
    const helloEvent = eventWaiter.await('hello');
    helloService.hello();
    await helloEvent;
    assert(msg === '01');
  });
});

Keywords

egg

FAQs

Package last updated on 06 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts