Gathering detailed insights and metrics for pip-services3-commons-nodex
Gathering detailed insights and metrics for pip-services3-commons-nodex
Gathering detailed insights and metrics for pip-services3-commons-nodex
Gathering detailed insights and metrics for pip-services3-commons-nodex
npm install pip-services3-commons-nodex
Typescript
Module System
Min. Node Version
Node Version
NPM Version
79.1
Supply Chain
99.2
Quality
77.6
Maintenance
100
Vulnerability
100
License
Total Downloads
35,947
Last Day
4
Last Week
248
Last Month
1,550
Last Year
15,191
Minified
Minified + Gzipped
Latest Version
1.0.4
Package Id
pip-services3-commons-nodex@1.0.4
Unpacked Size
1.38 MB
Size
236.93 kB
File Count
607
NPM Version
8.19.3
Node Version
16.19.0
Publised On
06 Feb 2023
Cumulative downloads
Total Downloads
Last day
-50%
4
Compared to previous day
Last week
22.8%
248
Compared to previous week
Last month
-74.8%
1,550
Compared to previous month
Last year
34.3%
15,191
Compared to previous year
1
5
This module is a part of the Pip.Services polyglot microservices toolkit. It provides a set of basic patterns used in microservices or backend services. Also the module implemenets a reasonably thin abstraction layer over most fundamental functions across all languages supported by the toolkit to facilitate symmetric implementation.
The module contains the following packages:
Install the NPM package as
1npm install pip-services3-commons-nodex --save
Then you are ready to start using the Pip.Services patterns to augment your backend code.
For instance, here is how you can implement a component, that receives configuration, get assigned references, can be opened and closed using the patterns from this module.
1import { IConfigurable } from 'pip-services3-commons-nodex'; 2import { ConfigParams } from 'pip-services3-commons-nodex'; 3import { IReferenceable } from 'pip-services3-commons-nodex'; 4import { IReferences } from 'pip-services3-commons-nodex'; 5import { Descriptor } from 'pip-services3-commons-nodex'; 6import { IOpenable } from 'pip-services3-commons-nodex'; 7 8export class MyComponentA implements IConfigurable, IReferenceable, IOpenable { 9 private _param1: string = "ABC"; 10 private _param2: number = 123; 11 private _anotherComponent: MyComponentB; 12 private _opened: boolean = true; 13 14 public configure(config: ConfigParams): void { 15 this._param1 = config.getAsStringWithDefault("param1", this._param1); 16 this._param2 = config.getAsIntegerWithDefault("param2", this._param2); 17 } 18 19 public setReferences(refs: IReferences): void { 20 this._anotherComponent = refs.getOneRequired<MyComponentB>( 21 new Descriptor("myservice", "mycomponent-b", "*", "*", "1.0") 22 ); 23 } 24 25 public isOpen(): boolean { 26 return this._opened; 27 } 28 29 public open(correlationId: string, callback: (err: any) => void): void { 30 this._opened = true; 31 console.log("MyComponentA has been opened."); 32 callback(null); 33 } 34 35 public close(correlationId: string, callback: (err: any) => void): void { 36 this._opened = true; 37 console.log("MyComponentA has been closed."); 38 callback(null); 39 } 40 41}
Then here is how the component can be used in the code
1import { ConfigParams } from 'pip-services3-commons-nodex'; 2import { References } from 'pip-services3-commons-nodex'; 3import { Descriptor } from 'pip-services3-commons-nodex'; 4 5let myComponentA = new MyComponentA(); 6 7// Configure the component 8myComponentA.configure(ConfigParams.fromTuples( 9 'param1', 'XYZ', 10 'param2', 987 11)); 12 13// Set references to the component 14myComponentA.setReferences(References.fromTuples( 15 new Descriptor("myservice", "mycomponent-b", "default", "default", "1.0",) myComponentB 16)); 17 18// Open the component 19myComponentA.open("123", (err) => { 20 console.log("MyComponentA has been opened."); 21 ... 22});
For development you shall install the following prerequisites:
Install dependencies:
1npm install
Compile the code:
1tsc
Run automated tests:
1npm test
Generate API documentation:
1./docgen.ps1
Before committing changes run dockerized build and test as:
1./build.ps1 2./test.ps1 3./clear.ps1
The module is created and maintained by Sergey Seroukhov.
The documentation is written by Egor Nuzhnykh, Alexey Dvoykin, Mark Makarychev.
No vulnerabilities found.
No security vulnerabilities found.