Skip to content

Commit 4853070

Browse files
committed
[+] Apimap - Send engine name, engine version, framework name, framework version, database version and orm name in apimap meta
1 parent b11c2a0 commit 4853070

File tree

2 files changed

+48
-7
lines changed

2 files changed

+48
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Change Log
22

33
## [Unreleased]
4+
### Added
5+
- Apimap - Send engine name, engine version, framework name, framework version, database version and orm name in apimap meta.
6+
7+
### Changed
8+
- Apimap - Rename `database_type` to `database` in apimap meta.
49

510
## RELEASE 3.0.0-beta.0 - 2019-01-28
611
### Added

index.js

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,58 @@ exports.init = function(opts) {
1818
opts.connections = [opts.mongoose];
1919
}
2020

21-
exports.getLianaName = function () {
21+
exports.getLianaName = function getLianaName() {
2222
return 'forest-express-mongoose';
2323
};
2424

25-
exports.getLianaVersion = function () {
25+
exports.getLianaVersion = function getLianaVersion() {
2626
var lianaVersion = require('./package.json').version.match(REGEX_VERSION);
2727
if (lianaVersion && lianaVersion[0]) {
2828
return lianaVersion[0];
2929
}
3030
};
3131

32-
exports.getOrmVersion = function () {
32+
exports.getFrameworkName = function getFrameworkName() {
33+
if (!opts.framework) { return null; }
34+
return opts.framework.name || null;
35+
};
36+
37+
exports.getFrameworkVersion = function getFrameworkVersion() {
38+
if (!opts.framework) { return null; }
39+
40+
try {
41+
var frameworkVersion = opts.framework.version.match(REGEX_VERSION);
42+
if (frameworkVersion && frameworkVersion[0]) {
43+
return frameworkVersion[0];
44+
}
45+
} catch (error) {
46+
return null;
47+
}
48+
};
49+
50+
exports.getDatabaseName = function getDatabaseName() {
51+
return 'MongoDB';
52+
};
53+
54+
// NOTICE: Deprecated
55+
exports.getDatabaseType = exports.getDatabaseName;
56+
57+
exports.getDatabaseVersion = function getDatabaseVersion() {
58+
if (!opts.mongoose) { return null; }
59+
60+
opts.mongoose.db.command({ buildInfo: 1 }, function (error, info) {
61+
if (error || !info) {
62+
return null;
63+
}
64+
return info.version || null;
65+
});
66+
};
67+
68+
exports.getOrmName = function getOrmName() {
69+
return 'mongoose';
70+
};
71+
72+
exports.getOrmVersion = function getOrmVersion() {
3373
if (!opts.mongoose) { return null; }
3474

3575
try {
@@ -42,10 +82,6 @@ exports.init = function(opts) {
4282
}
4383
};
4484

45-
exports.getDatabaseType = function () {
46-
return 'MongoDB';
47-
};
48-
4985
exports.SchemaAdapter = require('./adapters/mongoose');
5086

5187
exports.getModels = function () {

0 commit comments

Comments
 (0)