diff --git a/loopback/common/methods/application/version.js b/loopback/common/methods/application/version.js new file mode 100644 index 000000000..6604d8e98 --- /dev/null +++ b/loopback/common/methods/application/version.js @@ -0,0 +1,26 @@ + +const packageJson = require(`${process.cwd()}/package.json`); + +module.exports = Self => { + Self.remoteMethod('version', { + description: 'Gets all models information', + accepts: [ + { + arg: 'ctx', + type: 'Object', + http: {source: 'context'} + } + ], + returns: { + type: 'Object', + root: true + }, + http: { + path: `/version`, + verb: 'GET' + } + }); + Self.version = async function(ctx) { + return packageJson.version; + }; +}; diff --git a/loopback/common/models/application.js b/loopback/common/models/application.js index 6bdc2c13a..65d01fa65 100644 --- a/loopback/common/models/application.js +++ b/loopback/common/models/application.js @@ -1,9 +1,11 @@ module.exports = function(Self) { require('../methods/application/status')(Self); + require('../methods/application/version')(Self); require('../methods/application/post')(Self); require('../methods/application/execute')(Self); require('../methods/application/executeProc')(Self); require('../methods/application/executeFunc')(Self); require('../methods/application/getEnumValues')(Self); + require('../methods/application/getEnumValues')(Self); }; diff --git a/loopback/common/models/application.json b/loopback/common/models/application.json index f79001585..c2b609e88 100644 --- a/loopback/common/models/application.json +++ b/loopback/common/models/application.json @@ -8,6 +8,12 @@ "principalId": "$everyone", "permission": "ALLOW" }, + { + "property": "version", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + }, { "property": "post", "principalType": "ROLE",