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

fluffy-core

v0.0.55

Published

A library for implementing microservice architecture fast and easy

Readme

Fluffy core

Fluffy core Is a TS library for simplifying communication between microservices in microservice architecture. It supports multiple providers such as NATS, Kafka, RabbitMQ and RedisStreams and provides unified interface for fast integration in a project.

GitHub of a project NPM of a project

THIS PROJECT IS STILL UNDER DEVELOPMENT!

Please be careful in case of using it in production!

Currently providers tested in request-response mode:

  • NATS
  • Kafka
  • RabbitMQ
  • RedisStreams

Please use it carefully and report any issues you find. I'll do my best to fix them. But some things may not work as expected at current stage.

How to use

It's simple, firstly create a provider object (you can use classes NATSProvider, KafkaProvider, RabbitMQProvider, RedisStreamsProvider)

const provider = new NATSProvider('localhost:4222')

Then you can pass the provider to FluffyCore constructor

const fc = new FluffyCore(provider)

Register a route, when registering you are able to specify several fields:

  • controller - a controller is what actually makes some useful things (here you should have your business logic)
  • topic - unique identifier of the route, you will make requests to this topic
  • middlewares - an array of controllers that will be executed before the controller
  • postware - an array of controllers that will be executed after the controller

middleware and postware are executed in the order they are specified and are optional fields

you can register a route like this:

fc.registerRoute({
    topic: 'test-topic',
        controller:
            async (msg: Message) => {
                console.log("Controller got message", msg)
                msg.resp = {
                    ok: true
                }
            },
        middlewares: [
            async (msg: Message) => {
                msg.safeMetadata = {
                    messageArrived: new Date(),
                }
            },
        ],
        postware: [
            async (msg: Message) => {
                msg.safeMetadata = {
                    ...msg.safeMetadata,
                    messageReadyToRespond: new Date(),
                }
            },
            async (msg: Message) => {
                msg.resp = {
                    ...msg.resp,
                    timeToProcess: msg.safeMetadata.messageReadyToRespond.getTime() - msg.safeMetadata.messageArrived.getTime()
                }
            }
        ],
})

You can store data such as authorization, userId context or something like this in safeMetadata field. This data will be available in all middlewares and postwares and will be cleared before sending response to the client.

Technically, you can use metadata field, but it's not recommended. This field won't be cleaned and used for internal purposes.

request field stores data of request, for example object

{
  "hello": "world",
  "page": 1,
  "pets": [
    "dog",
    "cat" 
  ]
}

id field is an unique uuid identifier of request, you shall not use it!!!

resp is a field where you can save a response of your controller, this data will be returned to your bussiness logic on the requester side.

You can set an error handler for cases when your business logic throws an error

fc.setErrorProcessor(async ({ msg, e }: { msg: Message, e: any }) => {
        msg.resp = e
        msg.isError = true;
})

It's a recommended way to handle errors, you can customize it as you wish. It's basically just a controller.

After you configured your service, you call

await fc.start()

to start listening for requests of make requests from this fc instance.

You can make a request using makeRequest method or makeRequestSimplify. makeRequest method will return a response of your request as Message object and you can do things with it as you wish. makeRequestSimplify will throw an error if request failed (if isError field is true) or return a response if it was successful. Only resp field will be returned.

await fc.makeRequestSimplify({
    topic: 'test-topic',
    data: { hello: 'world' }
})

OR

await fc.makeRequest({
    topic: 'test-topic',
    data: {
        hello: 'world'
    }
})

You don't have to return anything from your controller, all modifications of response, context or metadata you should do inside msg object that was provided to your controller.

You can use your own provider, if available options are not enough for you. You just have to implement IProvider interface.

Here are some performance tests

Perfomed in single thread, locally, on 100, 1000, 10000, 100000 and 1000000 requests averanged in request-reply mode.

| Technology | RPS (Requests Per Second) | |---------------|---------------------------| | NATS | 783 | | Kafka | 330 | | Redis Streams | 649 | | RabbitMQ | 664 |

In conclusion

The library is still under development, but it's already usable, not stable, there are some tests that I have to perform, but it's usable. And oh gosh how i sufferred several years ago when I had to implement similar request-reply logic for Kafka, I hope this library won't make you suffer too.