New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bettercorp/service-base

Package Overview
Dependencies
Maintainers
2
Versions
443
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bettercorp/service-base

This base allows for a distributed service platform.

  • 2.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
479
increased by190.3%
Maintainers
2
Weekly downloads
 
Created
Source

Service base for distributed Services

This base allows for a distributed service platform.

Plugins

Create ts/js files according to your new plugin:

src/<plugin-name>/plugin.ts

lib/<plugin-name>/plugin.js

Core plugins

Logger

src/logging/plugin.ts

exports.default = {
  info: (pluginName: string, ...data: any[]) => typeof data === 'string'  
    ? console.log(`[${pluginName.toUpperCase()}] ${data}`)  
    : console.log(pluginName.toUpperCase(), data),  
  error: (pluginName: string, ...data: any[]) => typeof data === 'string'  
    ? console.error(`[${pluginName.toUpperCase()}] ${data}`)  
    : console.error(pluginName.toUpperCase(), data),  
  warn: (pluginName: string, ...data: any[]) => typeof data === 'string'  
    ? console.warn(`[${pluginName.toUpperCase()}] ${data}`)  
    : console.warn(pluginName.toUpperCase(), data)  
}  

New plugin

src/<plugin-name>/plugin.ts

module.exports.init = (features: PluginFeature) => {
  // This function is called on plugin initialization
   
  features.onEvent('<event-name>', '<plugin-name>', (...args: any[]) => {
    if (args.length === 0) return;
    let objectOfInfo: any = args[0];

    // *objectOfInfo* is the data passed in to your event handler

    // If the event returns data    
    features.emitEvent(`<plugin-name>-<event-name>-result-${objectOfInfo.resultKey}`, '<result data object or string>');

    // If the event returns data but errors out
    features.emitEvent(`<plugin-name>-<event-name>-error-${objectOfInfo.resultKey}`, '<error message or string>');
  });
}

Pre-built plugins

@bettercorp/service-base-plugin-<plugin>

Using the base

import ServiceBase from '@bettercorp/service-base';

const SB = new ServiceBase();
SB.init();
SB.run();

FAQs

Package last updated on 28 Sep 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc