rethinkdb-proxy

0.0.6 • Public • Published

RethinkDB Proxy

Build Status npm version

Reverse proxy for RethinkDB

Make your RethinkDB publicly accessible through limiting what kind of queries can be executed on your RethinkDB database.

Introduction by Example

First, start the proxy.

$ rethinkdb-proxy --port 8125

Using the proxy, getting all users in the users table is allowed.

r.connect({ port: 8125 }).then((conn) => {
  r.table('users').coerceTo('array').run(conn)
    .then((results) => {
      // We have some results!
      console.log(results); // [{ name: 'jorge' }, ... ]
    });
});

But deleting the users is not:

import rethinkDBProxy from 'rethinkdb-proxy';
rethinkDBProxy({ port: 8125 });
 
r.connect({ port: 8125 }).then((conn) => {
  r.table('users').delete('array').run(conn)
    .catch((err) => {
      // We get an error!
      console.log(err); // RqlClientError: Cannot execute query. "DELETE" query not allowed
    });
});

Running rethinkdb-proxy

CLI

rethinkdb-proxy comes with a CLI out-of-the box:

rethinkdb-proxy --port 8125 

Module

You can also import rethinkdb-proxy into Node.js:

import rethinkDBProxy from 'rethinkdb-proxy';
rethinkDBProxy({ port: 8125, allowInsert: true });

Options

Port

Module Parameter CLI Parameter Default API Reference
port --port 8125

Port in which to listen for driver connections. You should point your driver to this port.

RethinkDB Host

Module Parameter CLI Parameter Default API Reference
rdbHost --rdb-host localhost connect

Host in which RethinkDB is running.

RethinkDB Port

Module Parameter CLI Parameter Default API Reference
rdbPort --rdb-host localhost connect

Host in which RethinkDB is running.

Databases

Module Parameter CLI Parameter Default API Reference
dbs --dbs [ ]

Database to allow access to. By default, all database are allowed except rethinkdb.

Allow System Database Access

Module Parameter CLI Parameter Default API Reference
allowSysDbAccess --allow-sys-db-access false

Allow access to the rethinkdb database. This is not allowed by default, because access to this database allows to delete all other data.

Tables

Module Parameter CLI Parameter Default API Reference
tables --tables [ ]

Tables to allow access to. Tables must include their database db.table.

Allow Writes

Module Parameter CLI Parameter Default API Reference
allowWrites --allow-writes false

Allow all operations that write to the database (insert, update, delete).

Allow insert

Module Parameter CLI Parameter Default API Reference
allowInsert --allow-insert false insert

Allow insert queries.

Allow update

Module Parameter CLI Parameter Default API Reference
allowUpdate --allow-update false update

Allow update queries.

Allow delete

Module Parameter CLI Parameter Default API Reference
allowDelete --allow-delete false delete

Allow delete queries.

Allow replace

Module Parameter CLI Parameter Default API Reference
allowReplace --allow-replace false replace

Allow replace queries.

Allow dbCreate

Module Parameter CLI Parameter Default API Reference
allowDbCreate --allow-db-create false dbCreate

Allow dbCreate queries

Allow dbDrop

Module Parameter CLI Parameter Default API Reference
allowDbDrop --allow-db-drop false dbDrop

Allow dbDrop queries

Allow tableCreate

Module Parameter CLI Parameter Default API Reference
allowTableCreate --allow-table-create false tableCreate

Allow tableCreate queries.

Allow tableDrop

Module Parameter CLI Parameter Default API Reference
allowTableDrop --allow-table-drop false tableDrop

Allow tableDrop queries.

Allow Indexes

Module Parameter CLI Parameter Default API Reference
allowIndexes --allow-indexes false

Allow all operations on indexes (indexCreate, indexDrop, indexRename).

Allow indexCreate

Module Parameter CLI Parameter Default API Reference
allowIndexCreate --allow-index-create false indexCreate

Allow indexCreate queries.

Allow indexDrop

Module Parameter CLI Parameter Default API Reference
allowIndexDrop --allow-index-drop false indexDrop

Allow indexDrop queries.

Allow indexRename

Module Parameter CLI Parameter Default API Reference
allowIndexRename --allow-index-rename false indexRename

Allow indexRename queries.

Allow reconfigure

Module Parameter CLI Parameter Default API Reference
allowReconfigure --allow-reconfigure false reconfigure

Allow reconfigure queries.

Allow rebalance

Module Parameter CLI Parameter Default API Reference
allowRebalance --allow-rebalance false rebalance

Allow rebalance queries.

Allow http

Module Parameter CLI Parameter Default API Reference
allowHttp --allow-http false http

Allow queries with the http term.

Allow js

Module Parameter CLI Parameter Default API Reference
allowJavascript --allow-javascript false js

Allow queries with the js term.

Readme

Keywords

none

Package Sidebar

Install

npm i rethinkdb-proxy

Weekly Downloads

2

Version

0.0.6

License

MIT

Last publish

Collaborators

  • thejsj