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

turtlecoin-api-proxy

v1.0.0

Published

Provides an easy to use proxy interface for interacting with multiple TurtleCoin Nodes

Downloads

14

Readme

NPM

TurtleCoind Node API Proxy

This project is designed to provide an API proxy for web services to contact any number of TurtleCoin nodes for basic information regarding the state of the Node. It utilizes a cache that helps speed up the delivery of responses to clients while minimizing the load against the specified daemon by remote callers.

The sample service.js includes an example of how to quickly spin up the web service. It supports clustering via PM2 and I highly recommend that you run it with multiple threads.

Dependencies

Easy Start

This will spin up a copy of the webservice on 0.0.0.0:80. See the additional options below to customize the port or IP the web service binds to.

git clone https://github.com/turtlecoin/turtlecoin-api-proxy.git
cd turtlecoin-api-proxy
npm install
node service.js

Keep it Running

I'm a big fan of PM2 so if you don't have it installed, the setup is quite simple.

npm install -g pm2@latest
pm2 startup
pm2 install pm2-logrotate
pm2 start service.js --watch --name turtlecoin-api-proxy -i max
pm2 save

Initialization

This is incredibly simple to setup and use. No options are required but you can customize it as you see fit. Default values are provided below.

const TRTLProxy = require('./')

var service = new TRTLProxy({
  cacheTimeout: 30, // How quickly do we timeout cached responses from individual nodes
  timeout: 2000, // How long to wait for underlying RPC calls to return
  bindIp: '0.0.0.0', // What IP address do we bind the web service to
  bindPort: 80 // What port do we bind the web service to
  defaultHost: 'public.turtlenode.io', // The default node to look to for RPC calls
  defaultPort: 11898 // The default port to use on the default node
})

Methods

service.start()

Starts the web service

service.start()

service.stop()

Stops the web service

service.stop()

Events

Event - error

Event is emitted when an error is encountered.

service.on('error', (err) => {
  // do something
})

Event - ready

Event is emitted when the web service is listening for connections.

service.on('ready', (ip, port) => {
  // do something
})

Event - stop

Event is emitted when the web service is stopped.

service.on('stop', () => {
  // do something
})

Using the API

Refer to the TurtleCoin documentation for the API commands supported. Generally speaking, all commands from the JSON HTTP API and JSON RPC API are supported.

Querying Multiple Nodes

To query a node other than the one supplied in defaultHost call any of the API commands in one of the following formats:

  • /endpoint
  • /:node:/endpoint
  • /:node:/:port:/endpoint

Examples:

  • /getinfo
  • /public.turtlenode.io/getinfo
  • /public.turtlenode.io/11898/getinfo
  • /json_rpc
  • /public.turtlenode.io/json_rpc
  • /public.turtlenode.io/11898/json_rpc

License

Copyright (C) 2018-2019 Brandon Lehmann, The TurtleCoin Developers

Please see the included LICENSE file for more information.