0.2.4 • Published 4 years ago

moleculer-service v0.2.4

Weekly downloads
13
License
MIT
Repository
-
Last release
4 years ago

Moleculer Service

TypeScript decorators for Moleculer.

Install

$ npm install moleculer-service

Example

import { Context } from 'moleculer';
import { Service, service, action, event } from 'moleculer-service';

type WelcomeParams = {
  name: string;
};

@service('greeter')
class GreeterService extends Service {
  @action('hello')
  public async hello(ctx: Context) {
    return 'Hello, World!';
  }

  @action({
    name: 'welcome',
    params: {
      name: 'string',
    },
  })
  public async welcome(ctx: Context<WelcomeParams>) {
    return `Welcome, ${ctx.params.name}!`;
  }

  @event('some.event')
  public async onSomeEvent(payload: Record<string, any>, sender: string, eventName: string) {
    this.logger.info(`Event[${sender}][${eventName}]: ${JSON.stringify(payload)}`);
  }
}
0.2.1

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.4

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.0

4 years ago