Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tool-db-cli

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tool-db-cli

run tooldb command from commandline

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

tool-db-cli

DISCLAIMER: WORK IN PROGRESS/NOT PRODUCTION-READY

tool-db runs a tool-db server from your command line

Installation

npm i -g tool-db-cli

Example: Watching an expression

Start local tool-db server:

tool-db serve watch=foobar

Connect and put data from another local server:

tool-db put --peers=0.0.0.0:8000 foobar myvalue

Example: Using repl

Start local tool-db server with --repl

tool-db serve --repl

Output


ToolDB node running at http://127.0.0.1:8080

Storage:  tooldb
>

You can access access tooldb instance directly from repl

> await tooldb.anonSignIn();
> await tooldb.putData("key", "value")

Example: Creating a redundant mesh network

Connecting two browsers, A and B, over a mesh of tool-db peers, 1 through 4

start a small mesh network of tool-db servers, each listening on a different IP and saving data in a different folder.

tool-db --host=8081 --peers=127.0.0.1:8083,127.0.0.1:8084  --storageName=data1 # 1
tool-db --host=8082 --peers=127.0.0.1:8083,127.0.0.1:8084  --storageName=data2 # 2

tool-db --host=8083 --peers=127.0.0.1:8081,127.0.0.1:8082  --storageName=data3 # 3
tool-db --host=8084 --peers=127.0.0.1:8081,127.0.0.1:8082  --storageName=data4 # 4

On client side

<script src="https://unpkg.com/tool-db/bundle.js">
<script>
    const { ToolDb } = tooldb;
    const tdb = new ToolDb({ peers: [{ host: "localhost", port: 8080 }], debug: true });
</script>

now play around with shutting down individual peers and bringing them back online

As long as there is a path through the mesh network, the heartbeats will propagate from B to A.

But if peers 1 and 2 (or peers 3 and 4) simultainiously go down, A and B are seperated and updates won't go through. However, ToolDB peers will try to reestablish the connection to a lost peer, so as soon as you bring one of the peers back online, they will reconnect and updates will go through again.

Usage

tool-db serve

start tool-db server on http

Options:
  --version      Show version number                                   [boolean]
  --help         Show help                                             [boolean]
  --db           database name to use                                   [string]
  --storageName  our storage namespace              [string] [default: "tooldb"]
  --peers        comma-seperated list of URLs and IPs                   [string]
  --watch        comma-separated list of keys to watch                  [string]
  --host         set ip to listen on             [string] [default: "127.0.0.1"]
  --port         set port to listen on                  [number] [default: 8080]
  --repl         go into a repl (with tooldb instace)                     [boolean]
  --debug        enable debug mode                    [boolean] [default: false]

FAQs

Package last updated on 16 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc