Over the Network

Configuring an over-the-network instance and connecting to it

How over-the-network connections work

Running a network-exposed instance

When you install tydb locally (npm i tydb) or globally (npm i -g tydb), you'll get a CLI tool to run a network exposed instance of TyDB.

Before you run the command, you'll have to setup a configuration file, written in typescript, with a name that ends with .tydb.ts like this:

Using a node process manager

To run such TyDB in production you may need to have some kind of process manager, this is not included to give you more freedom and choice over which process manager you'd like to have, here's an example of how to do it using PM2 as an example.

After installation of TyDB and PM2 and creating your configs file (e.g. tydb.config.js) run this command:

If you have TyDB globally installed, then run npm root -g to locate the directory in which TyDB is installed. The bin.js file is found in dist directory, so your pm2 command may look like this:

After running the pm2 start command, run the log command

There shouldn't be any errors being logged. And to make sure that your database is being served over the network, head to your browser and type in the host name with the port (e.g. http://localhost:3000), and you should be greeted with a response like this one:

And when adding the database namespace to the URL (e.g. http://localhost:3000/ns1) and you should see a message like this one:

Connecting to the remote instance

Finally, to connect to the database that you've created above, use the connection URL as described in database configuration documentation as the ref.

Last updated

Was this helpful?