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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@precision-ss/core

v1.8.0

Published

A utility library created by Precision Software Solutions LLC.

Readme

Precision Software Solutions - Core Utility Library

A lightweight Node.js utility library providing robust error handling, structured logging, and an easy-to-use Express-based API server with optional Socket.IO support.

Overview

PCore Utility Library simplifies common backend needs by offering:

  • PCoreError: Consistent, extendable error objects with HTTP status codes and rich context.
  • PCoreLogger: Structured, leveled logging built on pino, with dynamic namespace support.
  • PCoreServer: A singleton Express.js HTTP server wrapper with optional Socket.IO integration, flexible middleware management, and common HTTP parsing & security helpers.

Installation

npm install @precision-ss/core

Quick Start

Importing

import pss from '@precision-ss/core';

PCoreError

Create rich, consistent error objects with built-in HTTP status codes and detailed context.

import pss from '@precision-ss/core';

// Custom server error
throw pss.error.Server('Something went wrong');

// Validation error wrapping a Zod error
try {
  // validate something
} catch (zErr) {
  throw pss.error.Validation(zErr);
}

// Not found error example
throw pss.error.NotFound('User', userId);

// Unauthorized and Forbidden examples
throw pss.error.Unauthorized();
throw pss.error.Forbidden('user123', '/admin');

PCoreLogger

Built on top of pino with added features:

  • Custom log levels including "story" for business-meaningful logs.
  • Namespace support for scoped logging.
  • Dynamic global log level control.
    • change levels and base bindings at runtime across all loggers
  • Redacts sensitive keys (key, secret, password).
import pss from '@precision-ss/core';

log.setLevel('info');

const logger = log.create({ app: 'myapp' }, 'module', 'submodule');

logger.debug('Does not print');
logger.info('Application started');
logger.story({ userId: 123 }, 'User logged in');
logger.error(new Error('Something bad'));

log.setLevel('debug');

logger.debug('Prints this time!');

PCoreServer

Initialize and Start

import pss from '@precision-ss/core';

pss.server.init({
  port: 4000,
  enableSockets: true,
  socketOptions: {
    // Socket.IO options
  }
});

await server.start();

Register Middleware & Routes

import pss from '@precision-ss/core';
import express from 'express';

// Add JSON parsing middleware
pss.server.enableJsonParsing();

// Add custom middleware
pss.server.useMiddleware((req, res, next) => {
  console.log('Request URL:', req.url);
  next();
});

// Add express router
const router = express.Router();

router.get('/hello', (req, res) => {
  res.send('Hello from PCore Server!');
});

pss.server.addRouter('/api', router);

Stop Server

import pss from '@precision-ss/core';

await server.stop();

Access Express and Socket.IO Instances

import pss from '@precision-ss/core';

const app = server.getApp();
const io = server.getIO();

Development & Testing

  • The server module provides a reset() method to clear internal state for isolated testing.
  • The HTTP server supports starting and stopping as promises for async control.
  • Access to the raw HTTP server is gated by PCORE_ALLOW_TEST=true environment variable to avoid accidental misuse.

License

This library is released under the MIT License. See the LICENSE file in the root of the project for details.

Contributing

Contributions, issues, and feature requests are welcome! Feel free to fork and submit pull requests.

Coming Soon

Wiki with details for all options and more detailed usage examples