You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
906 B
JavaScript

10 years ago
'use strict';
6 years ago
const nconf = require('nconf');
10 years ago
6 years ago
const databaseController = module.exports;
10 years ago
6 years ago
databaseController.get = async function (req, res) {
6 years ago
const results = {};
6 years ago
try {
if (nconf.get('redis')) {
const rdb = require('../../database/redis');
results.redis = await rdb.info(rdb.client);
}
if (nconf.get('mongo')) {
const mdb = require('../../database/mongo');
results.mongo = await mdb.info(mdb.client);
}
if (nconf.get('postgres')) {
const pdb = require('../../database/postgres');
results.postgres = await pdb.info(pdb.pool);
}
} catch (err) {
Object.assign(results, { error: err });
// Override mongo error with more human-readable error
6 years ago
if (err.name === 'MongoError' && err.codeName === 'Unauthorized') {
err.friendlyMessage = '[[admin/advanced/database:mongo.unauthorized]]';
delete results.mongo;
}
6 years ago
}
res.render('admin/advanced/database', results);
10 years ago
};