Skip to content

beyondessential/tamanu-meta-server

Repository files navigation

Tamanu Meta Server

Tamanu is an open-source patient-level electronic health records system for mobile and desktop.

The Meta service provides:

  • a server discovery service for the Tamanu mobile app
  • a server list and health check page
  • a range of active versions

Get

We have a container image for linux/amd64 and linux/arm64:

ghcr.io/beyondessential/tamanu-meta:2.4.1

API

Authentication

Routes marked with 🔐 require authentication, which is achieved by presenting a client TLS certificate.

GET /servers

Get the full list of servers as JSON.

[
	{
		"id":"8960470f-5282-496e-86f5-21df8cf67d62",
		"name":"Dev (main)",
		"host":"https://central.main.internal.tamanu.io/",
		"rank":"dev"
	}
]

POST /servers 🔐

Add a server to the list.

Pass a JSON body:

{
	"name":"Dev (main)",
	"host":"https://central.main.internal.tamanu.io/",
	"rank":"dev"
}

Returns the server with its assigned ID:

{
	"id":"8960470f-5282-496e-86f5-21df8cf67d62",
	"name":"Dev (main)",
	"host":"https://central.main.internal.tamanu.io/",
	"rank":"dev"
}

PATCH /servers 🔐

Edit a server.

Pass a JSON body, all fields optional except for id:

{
	"id":"8960470f-5282-496e-86f5-21df8cf67d62",
	"name":"Test server (main)"
}

Returns the edited server with its assigned ID:

{
	"id":"8960470f-5282-496e-86f5-21df8cf67d62",
	"name":"Test server (main)",
	"host":"https://central.main.internal.tamanu.io/",
	"rank":"dev"
}

There's a "hidden" feature in the UI where if you Shift-click a row, it will copy its ID to the clipboard.

DELETE /servers 🔐

Remove a server from the list.

Pass a JSON body with the id field:

{
	"id":"8960470f-5282-496e-86f5-21df8cf67d62"
}

POST /reload 🔐

Force a reload of the statuses.

GET /versions

Returns the range of versions being used in production.

{
	"min": "2.1.0",
	"max": "2.3.4"
}

Develop

  • Install Rustup, which will install Rust and Cargo.
  • Clone the repo via git:
$ git clone [email protected]:beyondessential/tamanu-meta-server.git
  • Build the project:
$ cargo check
  • Run with:
$ cargo run
  • Tests:
$ cargo test

We recommend using Rust Analyzer or Rust Rover for development.

Migrations

  1. Install the diesel CLI tool: https://diesel.rs/guides/getting-started.html#installing-diesel-cli

  2. Create a migration

$ diesel migration generate some_name_here
  1. Write the migration's up.sql and down.sql

  2. Run the pending migrations:

$ diesel migration run
  1. Test your down:
$ diesel migration redo
  1. Run formatter:
$ cargo fmt

Releasing

On the main branch:

$ cargo release --execute minor // or patch, major

Install cargo-release with:

$ cargo install cargo-release