From 484ba30137e76c738e7038c50d63ab8b3d3ebb37 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 15 May 2019 11:53:57 +0200 Subject: [PATCH] =?UTF-8?q?#1427=20M=C3=A9todo=20rest=20para=20comprobar?= =?UTF-8?q?=20estado=20de=20backend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loopback/common/methods/application/status.js | 19 +++++++++++++++++++ loopback/common/models/application.js | 4 ++++ loopback/common/models/application.json | 12 ++++++++++++ loopback/server/model-config.json | 3 +++ 4 files changed, 38 insertions(+) create mode 100644 loopback/common/methods/application/status.js create mode 100644 loopback/common/models/application.js create mode 100644 loopback/common/models/application.json diff --git a/loopback/common/methods/application/status.js b/loopback/common/methods/application/status.js new file mode 100644 index 000000000..43cfe5b60 --- /dev/null +++ b/loopback/common/methods/application/status.js @@ -0,0 +1,19 @@ + +module.exports = Self => { + Self.remoteMethod('status', { + description: 'Gets the backend status', + returns: { + type: 'Object', + root: true + }, + http: { + path: `/status`, + verb: 'GET' + } + }); + + Self.status = async() => { + await Self.rawSql(`SELECT TRUE`); + return true; + }; +}; diff --git a/loopback/common/models/application.js b/loopback/common/models/application.js new file mode 100644 index 000000000..ff7599fac --- /dev/null +++ b/loopback/common/models/application.js @@ -0,0 +1,4 @@ + +module.exports = function(Self) { + require('../methods/application/status')(Self); +}; diff --git a/loopback/common/models/application.json b/loopback/common/models/application.json new file mode 100644 index 000000000..0bb489720 --- /dev/null +++ b/loopback/common/models/application.json @@ -0,0 +1,12 @@ +{ + "name": "Application", + "base": "VnModel", + "acls": [ + { + "property": "status", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} diff --git a/loopback/server/model-config.json b/loopback/server/model-config.json index 530229c41..20e22accd 100644 --- a/loopback/server/model-config.json +++ b/loopback/server/model-config.json @@ -46,5 +46,8 @@ }, "Schema": { "dataSource": "vn" + }, + "Application": { + "dataSource": "vn" } } \ No newline at end of file