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

sauromjs

v1.0.3

Published

Microservice messaging communicator using amqp

Readme

Messaging communicator for NodeJs microservice

npm install sauromjs

API

Import package

    const Saurom = require('sauromjs');

Request

Creating a request object

    const request = new Saurom.Request({
        instanceId: 'id1',            // Default: auto generate an uniq id. Each nodejs instance must have an uniq instance id, 
        mqUrl: 'amqp://localhost',    // Default 'amqp://localhost'
        timeout: 2000,                // Default 5000. Request timeout
    });

Connect to message queue

    request.connect()
        .then()
        .catch();

Call a repository's service

    request.call(repositoryName: string, serviceName: string, body: Object);

Example

    const request = new Saurom.Request();
    
    request
        .connect()
        .then(() => {
            request
                .call(
                    'MathRepository',
                    'sqrt',
                    {
                        number: 36,
                    }
                )
                .then((response) => {})
                .catch((error) => {});
        });

Service

Creating a service object

    const service = new Saurom.Service({
        repository: 'MathRepository',   // required
        instanceId: 'id2',              // default: auto generate an uniq id
        mqUrl: 'amqp://localhost',      // default 'amqp://localhost'. Queue url, using amqplib package to connect message queue. Please see http://www.squaremobius.net/amqp.node/channel_api.html#connect for detail           
    });

Connect to message queue

    service.connect()
        .then()
        .catch();

Define service

    service.register(serviceName: string, function(req, res) {
        // req: object - body was sent by request object
        // res: object
        //     - res.success(anyValue) : Send success response
        //     - res.error(Error object): Send error response
    });

Example

    const service = new Saurom.Service({
        repository: 'MathRepository', // required
    });
    
    service.register('sqrt', (req, res) => {
        const { number } = req;

        if (typeof number !== 'number') {
            res.error(new Error('Not a number'));
            return;
        }

        res.success(Math.sqrt(number));
    });
            
    service.connect();

Example

See more example at: https://github.com/nhuanhoangduc/sauromjs/tree/master/test

1. Request.js - Make request to UserRepository microservice

// --- Step 1: Import sauromjs package
const Saurom = require('sauromjs');


// --- Step 2: Create a Request object
const Request = new Saurom.Request();


// --- Step 3: connect to message queue
Request.connect()
    .then(async () => { // Connected
    
        // --- Step 4: Make request to repository with given service name and params
         
        try {
            // Call service 'sqrt' of MathRepository
            const sqrt = await Request.call(
                'MathRepository',
                'sqrt',
                {
                    number: 36,
                }
            );

            // Call service 'pow' of MathRepository
            const pow = await Request.call(
                'MathRepository',
                'pow',
                {
                    baseNumber: 6,
                    exponent: 2
                }
            );

            console.log(sqrt); // 6
            console.log(pow); // 36
        } catch (error) {
            console.log(error);    
        }
    })
    .catch((err) => {
        console.log(err);
    });

2. MathRepository.js - Receive request message and send response message

// --- Step 1: Import sauromjs package
const Saurom = require('sauromjs');


// --- Step 2: Create a Service object
const Service = new Saurom.Service({
    repository: 'MathRepository', // required
});


// --- Step 3: Define services for repository MathRepository
        
// Service 'sqrt' of repository MathRepository
Service.register('sqrt', (req, res) => {
    const { number } = req;

    if (typeof number !== 'number') {
        res.error(new Error('Not a number'));
        return;
    }

    res.success(Math.sqrt(number));
});

// Service 'pow' of repository MathRepository
Service.register('pow', (req, res) => {
    const { baseNumber, exponent } = req;

    if (typeof baseNumber !== 'number') {
        res.error(new Error('Not a number'));
        return;
    }


    res.success(Math.pow(baseNumber, exponent));
});


// --- Step 4: connect to message queue
Service.connect()
    .then(() => { // Connected
        
    })
    .catch((err) => {
        console.log(err);
    });