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',
},
provider: 'rds',
authentication: (req, res, next) => next(),
debug: true,
})
);
app.listen(3000, () => {
console.log('Example app listening on port 3000!');
});
Options #
Option | Type | Default | Description |
---|
credentials | Object | null | An object with a connectionString property or individual connection properties. |
provider | String | '' | The database provider. One of: 'rds', 'heroku', or 'gcloud' |
authentication | Function | null | An Express.js middleware function. |
debug | Boolean | false | Logs debug information to the stdout/stderr. |