First, you need to have Node.js installed. The official website for Node.js is nodejs.org.
Use via npx
You can use MoonDB via the
By using the
npx command, you can use MoondDB without any installation. Any arguments you pass to
npx command is valid to MoonDB.
Install & Use
You can also install MoonDB via npm, then use it as a command line tool.
# install npm i -g moondb # use moondb
Server mode & Client mode
Moondb is a tool for both server and client mode, by default, if you run
moondb without any arguments, it will act as both server & client.
moondb --server [--token=xxxx] ## echo [moondb] running in [server] mode ... [moondb] server url: http://localhost:3002/rpc [moondb] token: xxxx
In server mode, it will just launch a server to communicate with both database servers & clients, but no UI available. You can use any client (e.g. https://moon.tinkink.co) to connect to the server. Just type in the server url & token.
For security reason, you can specify a token to connect to the server. If you don't specify a token, then MoonDB will generate a random token for you, and print to the console.
moondb --client ## echo [moondb] running in [client] mode ... [moondb] client running on http://localhost:3002
If you run MoonDB in client mode, it will just serve as a client, and you can use it to connect to the server.
Summary & Notes
A server and a client doesn't need to be same origin. You can just deploy an instance in server mode to a Linux server, and connect to it via any client.
When connect to a server, the requests are sent to server directly from your local browser, no requests are sent to client hosts.
Note: Moden browsers will restrict the requests for
http protocol on a
https page. So, if your client is hosted with
https protocol, you can't connect to a server with
http protocol, by default.
How to deal:
- Visit the client page
- Click the lock icon besides the url
- Click the
- Change the "unsafe content" to "Allow"