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

@nivinjoseph/n-svc

v3.0.6

Published

Service Application Framework

Readme

n-svc

Service Application Framework

Overview

n-svc is a robust service application framework designed for building scalable and maintainable Node.js services. It provides a structured way to create, manage, and control service applications with built-in support for dependency injection, logging, configuration management, and graceful shutdown handling.

Features

  • Dependency Injection using @nivinjoseph/n-ject
  • Configurable logging with @nivinjoseph/n-log
  • Configuration management with @nivinjoseph/n-config
  • Graceful shutdown handling
  • Program lifecycle management
  • TypeScript support
  • Modular and extensible architecture

Installation

npm i @nivinjoseph/n-svc

or 

yarn add @nivinjoseph/n-svc

Quick Start

import { SvcApp } from "@nivinjoseph/n-svc";
import { ConsoleLogger } from "@nivinjoseph/n-log";
import { ComponentInstaller, Registry } from "@nivinjoseph/n-ject";

// Define your program
class MyProgram {
    async start(): Promise<void> {
        // Initialize your service
    }

    async stop(): Promise<void> {
        // Clean up resources
    }
}

// Create and configure the service
const service = new SvcApp();

service
    .useLogger(new ConsoleLogger())
    .useInstaller(new MyInstaller())
    .registerProgram(MyProgram)
    .bootstrap();

Core Concepts

SvcApp

The main application class that orchestrates the service lifecycle. It provides methods for:

  • Configuring logging
  • Installing dependencies
  • Registering the main program
  • Managing shutdown and cleanup

Program

The core interface that your service must implement:

interface Program {
    start(): Promise<void>;
    stop(): Promise<void>;
}

Component Installation

Use the ComponentInstaller interface to register dependencies:

class MyInstaller implements ComponentInstaller {
    install(registry: Registry): void {
        registry
            .registerSingleton("MyService", MyService)
            .registerInstance("Config", config);
    }
}

Configuration

The framework uses @nivinjoseph/n-config for configuration management. Configuration can be provided through:

  • Environment variables
  • Configuration files
  • Command line arguments

Logging

Built-in support for logging through @nivinjoseph/n-log:

import { ConsoleLogger } from "@nivinjoseph/n-log";

const logger = new ConsoleLogger({
    useJsonFormat: true // For production environments
});

Shutdown Management

The framework handles graceful shutdown through:

  • SIGTERM and SIGINT signals
  • Programmatic shutdown
  • Resource cleanup
  • Disposable actions

Dependencies

  • @nivinjoseph/n-config
  • @nivinjoseph/n-defensive
  • @nivinjoseph/n-exception
  • @nivinjoseph/n-ext
  • @nivinjoseph/n-ject
  • @nivinjoseph/n-log
  • @nivinjoseph/n-util

Requirements

  • Node.js >= 20.10
  • TypeScript support

Contributing

Contributions are welcome! Please follow the existing code style and include tests for new features.

License

This project is licensed under the MIT License - see the LICENSE file for details.