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 🙏

© 2024 – Pkg Stats / Ryan Hefner

dooms

v1.0.0

Published

A RPC microservices framework for [Node.js](https://nodejs.org), loads a directory as a microservice, calls remote functions in it like **s1.say.hi()** or **call('s1:/say/hi')**. Dooms is based on [gRPC-node](https://github.com/grpc/grpc-node), but no [pr

Downloads

6

Readme

Dooms

A RPC microservices framework for Node.js, loads a directory as a microservice, calls remote functions in it like s1.say.hi() or call('s1:/say/hi'). Dooms is based on gRPC-node, but no proto files needed, more easy to use.

Server Environment

1. Install Docker (Docker CE recommended)

2. Install Redis in Docker
1) Install: docker pull redis
2) Start: docker run --restart=always --name redis -d -p 6379:6379 -it redis redis-server

Install

npm install dooms --save

Test

Download this repo

git clone https://github.com/hiowenluke/dooms.git
cd dooms
npm install

Test

npm test

TRY IT!

To run this demo, download this repo first if not yet (see above).

1. Run microservices

1) Open a new tab in terminal, then:

node ./examples/service1
# Service s1 is running...

2) Open a new tab in terminal, then:

node ./examples/service2
# Service s2 is running...

2. Run client

1) Open a new tab in terminal, then:

node ./examples/client-with-object-style

# Microservices #1
# Microservices #2
# { msg: 'Hi, I\'m owen, 100 years old.' }

2) Open a new tab in terminal, then:

node ./examples/client-with-message-style

# Microservices #1
# Microservices #2
# { msg: 'Hi, I\'m owen, 100 years old.' }

Usage

1. Create function files in directory "./src" in server project, such as below:

module.exports = async (name, age) => {
    return {msg: `Hi, I'm ${name}, ${age} years old.`};
};

2. Load the directory "./src" as a microservice named "s1" in index.js.

// "s1"
//      The name of this microservice.
//      It can be omitted if you have only one microservice.

// "./src"
//      The root folder name of business files such as "src/say/hi.js".
//      It can be omitted or replaced with other names such as "./biz", "./src", etc.
//      It should be started with ".".

require('dooms').initService('s1', './src');

3. Call like s1.say.hi()

const services = require('dooms').initClient();

const main = async () => {
    const {s1} = await services();
    const result = await s1.say.hi('owen', 100);
    console.log(result); // {msg: 'Hi, I\'m owen, 100 years old.'}
};

main();

4. Call like call('s1:/say/hi')

const call = require('dooms').initCall();

const main = async () => {
    const result = await call('s1:/say/hi', 'owen', 100);
    console.log(result); // {msg: 'Hi, I\'m owen, 100 years old.'}
};

main();

Options

1. For server

const options = {

    // Specify the gRPC options.
    // It can be omitted if the host is "localhost".
    gRPC: {
        host: 'localhost',      // gRPC host
    },

    // Specify the Redis options.
    // It can be omitted if it is the default options (like below) of Redis.
    redis: {
        host: 'localhost',      // Redis host
        // port: '6379',           // Redis port
        // db: 0,                  // Redis database number
        // family: 4,              // 4 (IPv4) or 6 (IPv6)
    },
};

Use it

require('dooms').initService('s1', './src', options);

2. For client

Only redis options required.

const options = {
    // Specify the Redis options.
    // It can be omitted if it is the default options (like below) of Redis.
    redis: {
        host: 'localhost',      // Redis host
        // port: '6379',           // Redis port
        // db: 0,                  // Redis database number
        // family: 4,              // 4 (IPv4) or 6 (IPv6)
    },
};

Use it

require('dooms').initClient(options);

Or

require('dooms').initCall(options);

Example

See files in directory examples to learn more.

Performance

Dooms is extended from gRPC-node. It is as fast as gRPC-node, much faster than socket.io-based RPC. (See Benchmark)

Why

License

MIT

Copyright (c) 2019, Owen Luke