GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - dev-ptera/nano-rpc-proxy: An Express proxy server used for filtering incoming Nano RPC requests.

BranchesTags
Open more actions menu

Latest commit

 

History

55 Commits
55 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/ISSUE_TEMPLATE
.github/ISSUE_TEMPLATE
 
 
demo
demo
 
 
src
src
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE.md
LICENSE.md
 
 
PUBLISHING.md
PUBLISHING.md
 
 
README.md
README.md
 
 
package.json
package.json
 
 
stack.png
stack.png
 
 
tsconfig.json
tsconfig.json
 
 
yarn.lock
yarn.lock
 
 

Repository files navigation

@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.

About

An Express proxy server used for filtering incoming Nano RPC requests.

Topics

bananoexpressnanocurrencynodejsproxyrpctypescript

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.