Skip to content

Latest commit

 

History

History
65 lines (46 loc) · 2.36 KB

File metadata and controls

65 lines (46 loc) · 2.36 KB

Mobnode Server

The API for the Mobnode application.

Usage

Simply install the project dependencies with yarn or npm.

$ yarn install
... or
$ npm install

Development

To develop for the Mobnode API, there are some configurations that have to be made in the .env file.

To get started quickly, copy the .env.example file committed to the repository.

$ cp .env.example .env

The API server strictly enforces SSL usage; therefore, we must supply a path to a valid certificate, key, and certificate authority. An example for how we develop interally is as follows.

SSL_KEY_PATH="/path/to/private/key.pem"
SSL_CERT_PATH="/path/to/certs/cert.pem"
SSL_CA_PATH="/path/to/ca-chain.cert.pem"

In addition to SSL configuration, it is also important to provide the host the API is running on, the main CouchDB user, and the secret that the CouchDB uses to successfully implement proxy authentication.

After all the configuration is done, simply run the server using yarn or npm.

API

This is the documentation for each of the endpoints on the Mobnode API.

Note: All POST, PUT, and DELETE requests only accept a Content-Type of application/json. This is for simplicity and security.

/api/nodes - The endpoint for maintaining the nodes (remote Mobnodes) in a given network.

  • GET - Retrieves all the nodes in a network
  • POST - Creates a new node given the proper JSON structure. The following fields are required.
    • node_name - A simple name for the node
    • host - The host name at which the remote Mobnode resides
    • port - The port at which the application is accessible
    • username - (Temporary) Used for remote authentication
    • password - (Temporary) Used for remote authentication
  • PUT - Batch updates nodes through CouchDB's bulk docs API. Instead of passing a JSON array with a key value of "docs", simply pass the array of nodes (following the specified JSON format in the POST request) with a key value of "nodes". Below is a visualization.
{
	"nodes": [
		{
			node_name: "mynode",
			...
		}
	]
}
  • DELETE - Uses the bulk docs API references above to delete docs in bulk. Follow the same convention as PUT, except use DELETE.