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

@synonymdev/feeds-daemon

v1.0.1

Published

A simple HTTP RPC deamon to enable publishing Slashtags Exchange Feeds.

Downloads

6

Readme

Slashtags Exchange Feeds Daemon

A simple HTTP RPC deamon to enable publishing Slashtags Exchange Feeds.

Import as Library

npm i @synonymdev/feeds-daemon 
const { Feeds } = require('@synonymdev/feeds-daemon')
const feeds = new Feeds({
    db: {
        name: 'feeds-db',
        path: "./data"
    },
    slashtags: "./",
    feed_schema: "<feed schema json file>"
})

await feeds.start()

// You can now call various functions

let feed = await feeds.getFeed({ user_id: "123123" })

How to run as Daemon

1. Setup config Go to ./schema/config.json Update config items.

2. Update your feeds slashfeed.json file This schema file allows feed consumers to parse the feed.

git clone
npm install
mkdir ./db
node start.js

Enable detailed logs DEBUG=stfeed:*

Run with PM2 pm2 start

README

A Postman collection has been provided.

Create Feed

Create an exchange feed for a user

/// Request Body
curl --location --request POST 'http://localhost:8787/v0.1/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "method":"createFeed",
    "params":{
        "user_id":"satoshi123"
    }
}'
/// Response
{
    "jsonrpc": "2.0",
    "id": "925b10c27f4ad350ab3ef7e027605fd83388c999a890cfdd8e6061656b5a5513",
    "result": {
        "slashdrive": {
            "key": "<string>",
            "encryption_key": "<string>"
        }
    }
}

Update Balance Feed

Update a wallet's balance for a user's feed.

curl --location --request POST 'http://localhost:8787/v0.1/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "method":"updateFeedBalance",
    "params":[
        {
            "user_id":"satoshi123",
            "wallet_name":"Bitcoin",
            "amount":1.442
        }
    ]
}'
/// Response
{
    "jsonrpc": "2.0",
    "id": "4fefad839fa440cc2a85d8178d1d895fa1044460080b8fe1a26b4942aa86c07f",
    "result": [
        true
    ]
}

Get Feed key by user id

curl --location --request POST 'http://localhost:8787/v0.1/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "method":"getFeed",
    "params":{ "user_id" : "satoshi123" }
}'
/// Response
{
    "jsonrpc": "2.0",
    "id": "c6ccd88f842330ab60153b5fb512101d2ab76824189eee5690f9070ebe18cb87",
    "result": {
        "feed_key": "<string>",
        "encrypt_key": "<string>"
    }
}

Delete User Feed

curl --location --request POST 'http://localhost:8787/v0.1/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "method":"deleteUserFeed",
    "params":{ "user_id" : "satoshi123" }
}'
/// Response
{
    "jsonrpc": "2.0",
    "id": "c6ccd88f842330ab60153b5fb512101d2ab76824189eee5690f9070ebe18cb87",
    "result": {
        "deleted": "true"
    }
}

Test & Development

There is a tests for all methods located in ./test dir

Dev Scripts

You can use the following scripts for dev.

  • ./util/CreateUsers.js Create Fake users
  • ./util/FakeFeed.js Broadcast a fake feed for users created in previous step
  • ./util/ListenRemoteFeed.js Listen to a exchange feed