@jjordy/service
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

@jjordy/Service


Basic Service

import Service, { Plugin, SentryPlugin, StatsDPlugin, DebugPlugin } from '@jjordy/service'

class CustomService extends Plugin {
  constructor() {
    super('CustomService')
  }
  public register () {
    this.doSomethingCool()
  }
  public async init () {
    // initialize your plugin
  }
  private doSomethingCool () {
    console.log('Do Something Cool')
  }
}

async function go() {
  try {
    const service = new Service()
    await service.registerPlugin<StatsDPlugin>('StatsDPlugin', new StatsDPlugin())
    await service.registerPlugin<SentryPlugin>('SentryPlugin', new SentryPlugin())
    await service.registerPlugin<DebugPlugin>(
      'DebugPlugin', new DebugPlugin({ name: 'My Custom service' }))
    await service.init()
    // provided by SentryPlugin
    service.logEvent('HEY THERE')
    service.logMessage('HEY THERE')
    service.logException('HEY THERE')
    // provided by DebugPlugin
    service.log("test")
    // provided by StatsDPlugin
    service.stats.increment('service.test.increments', 20)
    process.exit(0)
  } catch (err) {
    console.log('Uh oh something went wrong intializing the service', err)
  }
}

go()

Readme

Keywords

none

Package Sidebar

Install

npm i @jjordy/service

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

51 kB

Total Files

38

Last publish

Collaborators

  • jjordy