npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

basicservice

v1.0.3

Published

![npm](https://img.shields.io/npm/v/basicservice.svg) ![license](https://img.shields.io/npm/l/basicservice.svg) ![github-issues](https://img.shields.io/github/issues/the repositories url.svg) ![Circle CI build status](https://circleci.com/gh/the reposito

Readme

basicservice

npm license ![github-issues](https://img.shields.io/github/issues/the repositories url.svg) ![Circle CI build status](https://circleci.com/gh/the repositories url.svg?style=svg)

nodei.co

![travis-status](https://img.shields.io/travis/the repositories url.svg) ![stars](https://img.shields.io/github/stars/the repositories url.svg) ![forks](https://img.shields.io/github/forks/the repositories url.svg)

![forks](https://img.shields.io/github/forks/the repositories url.svg)

![](https://david-dm.org/the repositories url/status.svg) ![](https://david-dm.org/the repositories url/dev-status.svg)

Features

  • Common service for node js based mavenir microservices
  • Has built in support for DirectoryServcer registration (based on pub-sub)
    • Establishes connection to directory server (on start up). Will fail to load if directory server is not availble
    • Listens for "get service" requests (based on service type), will issue a request to DS and will locate to best service avalible
  • Manage depepncies for all common packages for nodes based micro-services

Install

npm install --save basicservice

Scripts

  • npm run start : node dist/index.js
  • npm run test : LOGGER=npm ./node_modules/.bin/mocha --compilers ts:ts-node/register --recursive ./test/**/*.spec.ts
  • npm run build : tsc
  • npm run readme : node ./node_modules/.bin/node-readme

Dependencies

Package | Version | Dev --- |:---:|:---: express | ^4.16.3 | ✖ json-serialize | ^1.1.3 | ✖ json-serializer | ^2.0.9 | ✖ mculogger | ^1.0.6 | ✖ module-alias | ^2.0.6 | ✖ node-uuid | ^1.4.8 | ✖ os-utils | 0.0.14 | ✖ readme-docs | ^0.1.1 | ✖ serialize-javascript | ^1.5.0 | ✖ thrift | ^0.11.0 | ✖ thrift-serializer | ^1.1.0 | ✖ ts-promise | ^1.0.0 | ✖ typescript-map | 0.0.6 | ✖ winston | ^2.4.2 | ✖ assert | ^1.4.1 | ✔ @types/chai | ^4.1.3 | ✔ @types/express | ^4.11.1 | ✔ @types/mocha | ^5.2.0 | ✔ @types/node | ^9.6.6 | ✔ chai | ^4.1.2 | ✔ mocha | ^5.1.1 | ✔ node-readme | ^0.1.9 | ✔ node-typescript-compiler | ^1.1.1 | ✔ nodemon | ^1.17.3 | ✔ npmlog | ^4.1.2 | ✔ ts-mockito | ^2.3.0 | ✔ ts-node | ^6.0.0 | ✔ typescript | ^2.8.3 | ✔

Author

Mavenir

License

  • N/A : null

Usage

Install

  • npm install basicservice-

Service

Once package is installed, you will need to extend two objects Service and an http service (not mandatory)

Service - DefaultService

  • Create YourService class

  • Extend DefaultService

  • Override:

    • getServicesList: Add to the default list you own apis (methods) as key value => key = thrift methods name, value your own implementation method name (best practice make it the same -:))
    public getServicesList(){
        let srvList = super.getServicesList();
        srvList["getAppDescription"] = this.getAppDescription;
        return srvList;
    }
    • getVersion should return the version (constant) from the thrift file

    -getServicePort should return the service port (constant) from the thrift file

    • getServiceType should return the service type (constant) from the thrift file

    • getAPI retruns the module name containing you own thrift generate code if you call super, it will look for common services (directory service) and throw an error if not supported. 1st look for your own service then call super.

        public getAPI(serviceType : number){
        switch (serviceType) {
            case 101:
            case 202:
                return myservice;
            default:
                return super.getAPI(serviceType);
        }
    }

HttpService - DefaultHttpService

  • Based on express package

  • Create YourHttpService class

  • Extend DefaultHttpService

  • Override configureRoutes to add more restfult api

    export class MyHttpService extends DefaultHttpService{
        constructor(service: DefaultService, port: number){
            super(service, port);
        }
    protected configureRoutes(): void {
            this.router.get('/dosomthing', (req, res) => {
                    res.status(200).send(JSON.stringify("ok"));
            });
    
            super.configureRoutes();
        }
    }
    • Note that http servie creation is not mandatory, If your service does not expose http (REST api) this step can be skipped.

Application - main

  • in your main script of your nodejs application, initalize the service objects. Init the Application object and start it. It will run hte thrift server
Application - service creation
  • Create a service (your.thrift) file
  • generate the relevant thrift conversions to nodejs
    • You will have to generate the thrift files for all the basic service dependencies plus your own.
    • Generate thrift based code (auto generated) for all services
    thrift1 -r --gen js:node pubsub_nostream.thrift 
    thrift1 -r --gen js:node directoryserverplugin.thrift
    thrift1 -r --gen js:node default.thrift
    thrift1 -r --gen js:node <myservice>.thrift
Application - main
  • Asuming you haev a service created (see above)

  • Instanciate Your Service & Http service (http is not a mandatory class)

  • Instanciate an application

  • start application

    var service : MyService = new MyService(adress);
    var http : MyHttpService = new MyHttpService(service, parseInt(port));
    
    //In this case http service is not exposed
    var application = new Application(MythriftService, service, undefined);
    
    application.start();