From 381e52600867db96164abff4350987b944b12087 Mon Sep 17 00:00:00 2001 From: David Routhieau Date: Fri, 8 Feb 2019 20:13:57 +0100 Subject: [PATCH] [+] Apimap - Send engine name, engine version, framework name, framework version, database version and orm name in apimap meta --- CHANGELOG.md | 2 ++ index.js | 29 ++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65817c75..19bfcb33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Change Log ## [Unreleased] +### Added +- Apimap - Send engine name, engine version, framework name, framework version, database version and orm name in apimap meta. ## RELEASE 3.0.0-beta.0 - 2019-01-28 ### Added diff --git a/index.js b/index.js index 03b6436b..9f7be92c 100644 --- a/index.js +++ b/index.js @@ -18,18 +18,37 @@ exports.init = function(opts) { opts.connections = [opts.mongoose]; } - exports.getLianaName = function () { + exports.getLianaName = function getLianaName() { return 'forest-express-mongoose'; }; - exports.getLianaVersion = function () { + exports.getLianaVersion = function getLianaVersion() { var lianaVersion = require('./package.json').version.match(REGEX_VERSION); if (lianaVersion && lianaVersion[0]) { return lianaVersion[0]; } }; - exports.getOrmVersion = function () { + exports.getDatabaseType = function getDatabaseType() { + return 'MongoDB'; + }; + + exports.getDatabaseVersion = function getDatabaseVersion() { + if (!opts.mongoose) { return null; } + + opts.mongoose.db.command({ buildInfo: 1 }, function (error, info) { + if (error || !info) { + return null; + } + return info.version || null; + }); + }; + + exports.getOrmName = function getOrmName() { + return 'mongoose'; + }; + + exports.getOrmVersion = function getOrmVersion() { if (!opts.mongoose) { return null; } try { @@ -42,10 +61,6 @@ exports.init = function(opts) { } }; - exports.getDatabaseType = function () { - return 'MongoDB'; - }; - exports.SchemaAdapter = require('./adapters/mongoose'); exports.getModels = function () {