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

@nestcfork/service

v0.7.5

Published

NestCloud is a Node.js micro-service solution, writing by Typescript language and Nest.js.

Readme

NestCloud - Service

Description

A NestCloud component for service registration and service discovery.

Installation

$ npm install @nestcfork/service --save

Quick Start

Import Module

This module dependency other modules, you need import @nestcfork/consul or @nestcfork/etcd module before import it.

import { Module } from '@nestjs/common';
import { resolve } from 'path';
import { ConsulModule } from '@nestcfork/consul';
import { ServiceModule } from '@nestcfork/service';
import { EtcdModule } from '@nestcfork/etcd';
import { BootModule } from '@nestcfork/boot';
import { BOOT, CONSUL, ETCD } from '@nestcfork/common';

@Module({
  imports: [
      BootModule.forRoot({
        filePath: resolve(__dirname, '../config.yaml'),
      }),
      // consul backend
      ConsulModule.forRootAsync({ inject: [BOOT] }),
      ServiceModule.forRootAsync({ inject: [BOOT, CONSUL] }),
      // etcd backend
      EtcdModule.forRootAsync({ inject: [BOOT] }),
      ServiceModule.forRootAsync({ inject: [BOOT, ETCD] }),
  ],
})
export class AppModule {}

config.yaml

service:
  discoveryHost: localhost
  id: your-service-id
  name: your-service-name
  port: 3000
  tags: ['v1.0.1']
  healthCheck:
    timeout: 1s
    interval: 10s
    route: /health
  maxRetry: 5
  retryInterval: 5000

Usage

import { Injectable } from '@nestjs/common';
import { InjectService, Service } from '@nestcfork/service';

@Injectable()
export class TestService {
  constructor(
    @InjectService() private readonly service: Service,
  ) {
  }

  getServiceServers() {
      const servers = this.service.getServiceServers('user-service', {passing: true});
      this.service.watch('user-service', nodes => {
          console.log(nodes);
      });
      console.log(nodes);
  }
}

Checks

Script + Interval

service:
  healthCheck:
    timeout: 1s
    interval: 10s
    script: /root/script/check.sh

Http + Interval

service:
  healthCheck:
    timeout: 1s
    interval: 10s
    protocol: http
    route: /health

Tcp + Interval

service:
  healthCheck:
    timeout: 1s
    interval: 10s
    tcp: localhost:3000

Time To Live

service:
  healthCheck:
    ttl: 60s

Docker + Interval

service:
  healthCheck:
    dockerContainerId: 2ddd99fd268c

API

class ServiceModule

static register(options: RegisterOptions): DynamicModule

Import nest consul service module.

| field | type | description | | :------------------------------------------------- | :------- | :-------------------------------------------------------------------------------------------- | | options.dependencies | string[] | if you are using @nestcfork/boot module, please set [BOOT] | | options.id | string | the service id | | options.name | string | the service name | | options.port | number | the service port, if not set, it will use random port | | options.tags | number | the service tags | | options.includes | string[] | sync services from consul, if not set, it will sync all services | | options.discoveryHost | string | the discovery ip | | options.healthCheck.timeout | number | the health check timeout, default 1s | | options.healthCheck.interval | number | the health check interval,default 10s | | options.healthCheck.deregisterCriticalServiceAfter | string | timeout after which to automatically deregister service if check remains in critical state | | options.healthCheck.protocol | string | https or http, default is http. | | options.healthCheck.tcp | string | host:port to test, passes if connection is established, fails otherwise. | | options.healthCheck.script | string | path to check script, requires interval. | | options.healthCheck.dockerContainerId | string | Docker container ID to run script. | | options.healthCheck.shell | string | shell in which to run script (currently only supported with Docker). | | options.healthCheck.ttl | string | time to live before check must be updated, instead of http/tcp/script and interval (ex: 60s). | | options.healthCheck.notes | string | human readable description of check. | | options.healthCheck.status | string | initial service status. | | options.healthCheck.route | string | the health check url, default is /health. | | options.maxRetry | number | the max retry count when register service fail | | options.retryInterval | number | the retry interval when register service fail |

class Service

getServices(): ServiceServer[]

Get all services with nodes.

getServiceNames(): string[]

Get all service names

watch(service: string, callback: (nodes: IServiceServer[]) => void): void

watch service nodes change

watchServiceList(callback: (services: string[]) => void): void

watch service name list change

Stay in touch

License

NestCloud is MIT licensed.