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

@dev-ptera/nano-rpc-proxy

v1.1.2

Published

Express app which proxies Nano RPC requests

Downloads

2

Readme

@dev-ptera/nano-rpc-proxy

This is an express app which filters incoming Nano RPC requests and queries a configured Nano node. It is intended that this app runs on the same machine as a fully synced Nano node.

For instructions on how to setup a Nano node, visit https://docs.nano.org/running-a-node/node-setup/

Usage

To install the package:

yarn add @dev-ptera/nano-rpc-proxy

or

npm i @dev-ptera/nano-rpc-proxy

Add the following to your typescript application:

import * as express from 'express';
import { NanoProxyServer } from '@dev-ptera/nano-rpc-proxy';


const server = new NanoProxyServer(express(), {
    
    /* Server message emitted when app starts listening on `port`. */
    APP_LISTENING_MSG: (port: number) => 
        `Running @dev-ptera/nano-rpc-proxy server on port ${port}.`,

    /* Server is expected to serve external requests. */
    IS_PRODUCTION: false,

    /* Nano/Banano Node RPC URL */
    NANO_RPC_URL: 'http://[::1]:7072',

    /* Server port when ran locally for development purposes. */
    APP_DEV_PORT: 1119,

    /* Server port when listening to outside requests. */
    APP_PROD_PORT: 1120,

    /* URL path where the app is served.  
       Example: http://[YOUR-IP]:[APP_DEV_PORT | APP_PROD_PORT]/[APP_PATH] 
    */
    APP_PATH: '',

    /* 
       List of enabled websites that can bypass server CORS restriction.
       CORS is not enforced when server is ran in development-mode.
    */
    URL_WHITE_LIST: ['http://localhost'],

    /*
       List of actions we can use with Nano RPC Protocol,
       Full list of actions & descriptions here: https://docs.nano.org/commands/rpc-protocol
     */
    ALLOWED_ACTIONS: ['account_balance']

    /*
     * Optional function ran to security-check incoming requests.
     * Runs after the CORS filter.
     */
    REQUEST_FILTER: (req: Request, res: Response, next: NextFunction) => void;
};
});

server.start();

Configuration

This server can be configured to support:

  • Whitelisted external domains.
  • Enabled/disabled RPC actions
  • Nano or Banano Nodes
  • Custom Server Ports & Server Path
  • etc.

All supported config options can be found in src/config.ts

Error Handling

This sever returns an error code 501 when a disabled action was requested by a client.
This server returns an error code 500 if a request is blocked by CORS or any other generic error happens within the proxy.

If the Nano RPC request returns an error response due to invalid or missing account info, JSON parsing issues, etc this proxy will return a status code 200 since the error was generated from the Nano Node.