@jjordy/service
v0.0.1
Published
A library for initializing a service oriented architecture
Downloads
2
Readme
@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()