Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
@mediarithmics/plugins-nodejs-sdk
Advanced tools
This is the mediarithmics nodejs to help plugin developers bootstrapping their plugin without having to deal with most of the plugin boilerplate
This is the mediarithmics SDK for building plugins in Typescript or raw Node.js easily. As this package includes Typescript interfaces, we recommend that you use it with Typescript to ease your development.
It covers (as of v0.2.0):
Coming soon:
This module is installed via npm:
npm install --save @mediarithmics/plugins-nodejs-sdk
The NodeJS plugin SDK consists of a set of abstract class that you have to implement. Those class provides a lot of helpers to make your life easier when having to make calls to the mediarithmics plugin gateway and/or to retrieve data.
This SDK also integrate a lot of very useful Typescript interfaces that we highly recommend you to use.
In order to implement your own logic while building your plugin, you have to override the "main" processing function of the abstract class in your impementation.
This function to override depend on the Plugin type. Those are:
If you need a custom Instance Context (see below), you can also override the 'instanceContextBuilder' function of the abstract class.
Once you will have provided your own implementation of the abstract class, you'll have to instantiate it and to give this instance to a 'Runner' that will run it as a web server app.
A mediarithmics plugin is called by the mediarithmics platform wih a 'Request' that contains all the Data to process / evaluate. Each type of plugin, depending on its functional behavior, is receiving a different request payload.
The plugin SDK contains a typescript interface describing the format of the request for each supported plugin.
A request can be:
Please see the complete documentation for each Plugin Type here.
A plugin instance can have a configuration that will change the way it will process Requests. As a plugin will be called numerous time to process incoming Requests, its configuration must be cached and only refreshed periodically. This SDK is helping you to manage this cache by providing you an "Instance Context" that represents this cache.
A default "Instance Context" is automatically provided by the SDK for each plugin type but you can also provide your own "Instance Context Builder" that will be called periodically to rebuild the cache.
If you need to have a custom Instance Context format because you pre-calculate or charge in memory some values (ex: if you need to compile a Template / load in memory a statistic model / etc.), you can:
Note: The plugin instance configuration can be done through the mediarithmics console UI or directly by API.
The SDK provides 2 different runners:
For details on how to use those 2 runners, please refer the examples code snippets provided with the SDK.
You have to import the 'core' module of the SDK in your code to access to the Abstract classes and Typescript interfaces. If you need some external integration, as the "Handlebar" templating system for example, you can also import the 'extra' package.
import { core } from "@mediarithmics/plugins-nodejs-sdk";
When implementing a plugin class, you need to give him the main 'processing' function that he will process every time a Request is being received.
export class MySimpleAdRenderer extends core.AdRendererBasePlugin<
core.AdRendererBaseInstanceContext
> {
protected async onAdContents(
request: core.AdRendererRequest,
instanceContext: core.AdRendererBaseInstanceContext
): Promise<core.AdRendererPluginResponse> {
.....
}
}
export class MyActivityAnalyzerPlugin extends core.ActivityAnalyzerPlugin {
protected onActivityAnalysis(
request: core.ActivityAnalyzerRequest,
instanceContext: core.ActivityAnalyzerBaseInstanceContext
): Promise<core.ActivityAnalyzerPluginResponse> {
......
}
}
Once you have implemented your own Plugin class, you have to instantiate it and to provide the instance to a Plugin Runner. For Production use, here is how you need to do it:
const plugin = new MyActivityAnalyzerPlugin();
const runner = new core.ProductionPluginRunner(plugin);
runner.start();
const plugin = new MySimpleAdRenderer();
const runner = new core.ProductionPluginRunner(plugin);
runner.start();
This SDK provides you a 'TestingPluginRunner' that you can use to mock the transport layer of the plugin (e.g. emulate its call to the platform) and which expose the plugin 'app' on which you can trigger fake calls to test your plugin logic.
The Plugin examples provided with the SDK are all tested and you can read their tests in order to build your own tests.
Testing Plugins is highly recommended.
0.2.1 - 2017-09-13
FAQs
This is the mediarithmics nodejs to help plugin developers bootstrapping their plugin without having to deal with most of the plugin boilerplate
The npm package @mediarithmics/plugins-nodejs-sdk receives a total of 179 weekly downloads. As such, @mediarithmics/plugins-nodejs-sdk popularity was classified as not popular.
We found that @mediarithmics/plugins-nodejs-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.