Magistrate Postgres Stats for Developers

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 #

OptionTypeDefaultDescription
credentialsObjectnullAn object with a connectionString property or individual connection properties.
providerString''The database provider. One of: 'rds', 'heroku', or 'gcloud'
authenticationobjectnullA Hapi.js route authentication object
debugBooleanfalseLogs debug information to the stdout/stderr.