Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @jjordy/service with all npm packages installed. Try it out:

var service = require("@jjordy/service")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@jjordy/service v0.0.1

A library for initializing a service oriented architecture

@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()

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free