Documentation

Hapi.js

Install the Plugin

npm install YOUR_MAGISTRATE_URL

Add the Plugin to Your App

const init = async () => {
  await server.register(require('inert'));
  await server.register(require('vision'));
  await server.register({
    plugin: require('magistrate/hapi'),
    options: {
      credentials: {
        host: 'localhost',
        port: 5432,
        user: 'postgres',
        password: 'postgres',
        database: 'sample',
      },
      // credentials: {
      //   connectionString: process.env.DATABASE_URL
      // },
      provider: 'rds',
      prefix: '/magistrate',
      authentication: false,
      debug: true,
    },
  });
  await server.start();
};

Hapi Magistrate requires vision and inert be loaded before.

Options

credentials
An object with a connectionString property or individual connection properties.
provider
One of:
['rds', 'heroku', 'gcloud']
prefix
The base url Magistrate uses to serve the dashboard. (https://example.com/magistrate)
authentication
A hapi.js route auth object.
debug
Logs debug information to the stdout/stderr.

Express.js

Install the Plugin

npm install YOUR_MAGISTRATE_URL

Add the Plugin to Your App

const express = require('express');
const magistrate = require('magistrate/express');

const app = express();

app.use(
  '/magistrate',
  magistrate({
    credentials: {
      host: 'localhost',
      port: 5432,
      user: 'postgres',
      password: 'postgres',
      database: 'sample',
    },
    // credentials: {
    //   connectionString: process.env.DATABASE_URL
    // },
    provider: 'rds',
    authentication: (req, res, next) => next(),
    debug: true,
  })
);

app.listen(3000, () => {
  console.log('Example app listening on port 3000!');
});

Options

credentials
An object with a connectionString property or individual connection properties.
provider
One of:
['rds', 'heroku', 'gcloud']
prefix
The base url Magistrate uses to serve the dashboard. (https://example.com/magistrate)
authentication
An express middleware function.
debug
Logs debug information to the stdout/stderr.