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

snapplibs

v1.0.35

Published

SNAPP Application

Readme

Snapplibs is a simple and fast common functionality library for node.js services:

/* The snapplibs library provides the common functionality to the SNAPP application. The developers can able to install the package from the SNAPP nexus library and they will consume e below functions */

1. logger
2. dateFormat
3. utcDateFormat
4. easternDateFormat
5. errorResponse
6. successResponse
7. badRequest
8. unAuthorized
9. forbidden
10. insernalServer


```js
    const {
        logger,
        dateFormatCCoE,
        utcDateFormat,
        easternDateFormat,
        errorResponse,
        successResponse,
        badRequest,
        unAuthorized,
        forbidden,
        insernalServer
    } = require('snapplibs');
```

installation

```sh
    npm install snapplibs
        (or)
    npm install snapplibs --save
        (or)
    npm install snapplibs --save-dev
```

Functions Implementation

Logger

In this library we are integrated as a bunyan framework. It is the CCoE approved library and it will return the logs as a JSON format followed by the CCoE patterns.

```js
    const {logger} = require('snapplibs');
    const obj = {
        name : 'SNAPP',
        version : 1.0.0
    }
    logger.info('Welcome to SNAPP Library', obj);
    logger.error('SNAPP error messages');
    logger.warn('Warning messages');
    logger.debug('Debug messages');
    logger.trace('Tracing messages');
```

Example output:

```sh
SNAPP INFO '{
        "name": "SNAPP",
        "hostname": "VDC1ITWB00019",
        "pid": 11576,
        "level": "info",
        "msg": "Welcome to snapplibs { name: 'SNAPP', version: 1.0.0 }",
        "time": "2022-02-10 19:39:21",
        "src": {
            "file": "C:\\Users\\z64525\\Nodejs\\Test code\\index.js",
            "line": 14,
            "func": "hai"
        },
        "v": 0,
        "_timeStamp": "2022-02-10T19:39:21+05:30",
        "logTransactionID": "b19dd267-f1f9-48e7-9d39-1c6a67323f6f"
    }'
```
------------------------------ ****************** -------------------------------------------

Date Format

In the date format we are used into the moment framework Here we are developed below date formats

1. dateFormatCCoE - CCoE pattern
2. utcDateFormat - UTC date and time formater
3. easternDateFormat - US Eastern date and time formater

```js 

    ** CCoE Pattern **

    const {dateFormatCCoE} = require('snapplibs');
    const date = dateFormatCCoE(new Date()); // The parameter should be a optional either user can pass or itshould be in empty. If it is a empty parameter the time will taken into the server time.

    Example output : 2022-02-10T19:39:21+05:30

    const date = dateFormatCCoE();
    or
    const date = dateFormatCCoE('2022-02-10');

    ----------------------------------------

    ** UTC Pattern **

    const {utcDateFormat} = require('snapplibs');
    const date  = utcDateFormat(new Date()); // Date parameter should be in optional. 
    
    Example output : 2022-02-10T14:09:21Z

    const date = utcDateFormat();
    or
    const date = utcDateFormat('2022-02-10');

    ------------------------------------------

    ** US Eastern pattern - This will converting into the UTC to US Eastern Zone **

    const {easternDateFormat} = require('snapplibs');
    const date = easternDateFormat(new date()); // Date parameter should be in optional.

    Example output : 2022-02-10T09:09:21Z

    const date = easternDateFormat();
    or
    const date = easternDateFormat('2022-02-10');

```

--------------------------------- ******* ------------------------------------

Response Structure

In the response structures we are handles the error and success scenarios.

/**
 * The success response should be either Object or Array of Object format.
 */

```js
    ** Success Response **
    const {successResponse} = require('snapplibs');
    const response = [
        {
            key1 : value1,
            key2 : value2
        }
    ]

    successResponse(response);

    or

    const responseObj = {
        key1 : value1
        key2 : value2
    };
    successResponse(responseObj);

    Example output:
    {
        "key1" : "value1"
        "key2" : "value2"
    }

    ** Error Response **
    const {errorResponse} = require('snapplibs');
    const errorObj = {
        status : 404,
        error : [
            statusCode : 404,
            message : "Data not found"
        ]
    }
    errorResponse({status:400, message:"Data not found"});

    Example output:

    {
        "status" : 404,
        "error" : [
            "statusCode" : 404,
            "message" : "Data not found"
        ]
    }

    const { 
        badRequest,
        unAuthorized,
        forbidden,
        insernalServer
    } = require('snapplibs');
    
    badRequest();
    unAuthorized();
    forbidden();
    insernalServer();
```