From 790630da4c3da36353f36208c71f653e1ab766b5 Mon Sep 17 00:00:00 2001 From: brandonkimmmm Date: Fri, 11 Jun 2021 16:36:16 +0900 Subject: [PATCH 01/10] trades stream response --- server/api/controllers/trade.js | 10 ++++++++-- server/api/swagger/swagger.yaml | 15 +++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/server/api/controllers/trade.js b/server/api/controllers/trade.js index 1faad76857..0128a4aee8 100644 --- a/server/api/controllers/trade.js +++ b/server/api/controllers/trade.js @@ -22,10 +22,13 @@ const getUserTrades = (req, res) => { toolsLib.order.getAllUserTradesByKitId(user_id, symbol, limit.value, page.value, order_by.value, order.value, start_date.value, end_date.value, format.value) .then((data) => { - if (format.value) { + if (format.value === 'csv') { res.setHeader('Content-disposition', `attachment; filename=${toolsLib.getKitConfig().api_name}-trades.csv`); res.set('Content-Type', 'text/csv'); return res.status(202).send(data); + } else if (format.value === 'all') { + res.status(203); + data.pipe(res); } else { return res.json(data); } @@ -51,10 +54,13 @@ const getAdminTrades = (req, res) => { promiseQuery .then((data) => { - if (format.value) { + if (format.value === 'csv') { res.setHeader('Content-disposition', `attachment; filename=${toolsLib.getKitConfig().api_name}-users-trades.csv`); res.set('Content-Type', 'text/csv'); return res.status(202).send(data); + } else if (format.value === 'all') { + res.status(203); + data.pipe(res); } else { return res.json(data); } diff --git a/server/api/swagger/swagger.yaml b/server/api/swagger/swagger.yaml index 7f80c07712..a59645ae5b 100644 --- a/server/api/swagger/swagger.yaml +++ b/server/api/swagger/swagger.yaml @@ -12,6 +12,7 @@ consumes: produces: - application/json - text/csv + - text/plain securityDefinitions: Bearer: @@ -1572,14 +1573,12 @@ paths: required: false type: number format: int32 - default: 50 - in: query name: page description: Page of data to retrieve required: false type: number format: int32 - default: 1 - in: query name: order_by description: Field to order data @@ -1607,7 +1606,7 @@ paths: name: format description: Specify data format required: false - enum: ['csv'] + enum: ['csv', 'all'] type: string responses: 200: @@ -1618,6 +1617,10 @@ paths: description: CSV schema: type: string + 203: + description: Stream + schema: + type: string default: description: Error schema: @@ -2983,7 +2986,7 @@ paths: name: format description: Specify data format required: false - enum: ['csv'] + enum: ['csv', 'all'] type: string tags: - Admin @@ -2996,6 +2999,10 @@ paths: description: CSV schema: type: string + 203: + description: Stream + schema: + type: string default: description: Error schema: From 2e2cb10fc394fd221271e335c0fd59a730399a12 Mon Sep 17 00:00:00 2001 From: brandonkimmmm Date: Tue, 22 Jun 2021 11:53:25 +0900 Subject: [PATCH 02/10] jsonstream and pg-query-stream install --- server/package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/package.json b/server/package.json index d364bc1ef5..98e335706e 100644 --- a/server/package.json +++ b/server/package.json @@ -15,6 +15,7 @@ "license": "bitHolla Inc.", "main": "app.js", "dependencies": { + "JSONStream": "1.3.5", "bcryptjs": "2.4.3", "bluebird": "3.5.3", "body-parser": "1.19.0", @@ -48,6 +49,7 @@ "otp": "0.1.3", "pg": "6.4.2", "pg-hstore": "2.3.2", + "pg-query-stream": "4.1.0", "pm2": "2.10.1", "pmx": "1.6.4", "random-string": "0.2.0", From 34e2d7eba245b34b6425048e80a3064d05d8c41f Mon Sep 17 00:00:00 2001 From: brandonkimmmm Date: Thu, 24 Jun 2021 11:52:30 +0900 Subject: [PATCH 03/10] use stream library during local testing --- server/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/package.json b/server/package.json index 98e335706e..0351efcc4f 100644 --- a/server/package.json +++ b/server/package.json @@ -29,8 +29,8 @@ "flat": "5.0.0", "geoip-lite": "1.4.1", "helmet": "3.12.0", - "hollaex-node-lib": "github:bitholla/hollaex-node-lib#2.2", - "hollaex-tools-lib": "github:bitholla/hollaex-tools-lib#2.4", + "hollaex-node-lib": "github:bitholla/hollaex-node-lib#streams", + "hollaex-tools-lib": "github:bitholla/hollaex-tools-lib#streams", "http": "0.0.0", "install": "0.10.4", "json2csv": "4.5.4", From 940856bbacc8ee1fd5bfb9d4d7ebf4d866ba80b3 Mon Sep 17 00:00:00 2001 From: brandonkimmmm Date: Thu, 24 Jun 2021 11:53:06 +0900 Subject: [PATCH 04/10] get admin trades stream initial --- server/api/controllers/trade.js | 89 ++++++++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 8 deletions(-) diff --git a/server/api/controllers/trade.js b/server/api/controllers/trade.js index 0128a4aee8..e4c1a2e7d7 100644 --- a/server/api/controllers/trade.js +++ b/server/api/controllers/trade.js @@ -47,19 +47,92 @@ const getAdminTrades = (req, res) => { let promiseQuery; if (user_id.value) { - promiseQuery = toolsLib.order.getAllUserTradesByKitId(user_id.value, symbol.value, limit.value, page.value, order_by.value, order.value, start_date.value, end_date.value, format.value); + if (format.value === 'all') { + promiseQuery = toolsLib.order.getUserTradesByKitIdStream( + user_id.value, + { + symbol: symbol.value, + limit: limit.value, + page: page.value, + orderBy: order_by.value, + order: order.value, + startDate: start_date.value, + endDate: end_date.value + } + ); + } else if (format.value === 'csv') { + promiseQuery = toolsLib.order.getUserTradesByKitIdCsv( + user_id.value, + { + symbol: symbol.value, + limit: limit.value, + page: page.value, + orderBy: order_by.value, + order: order.value, + startDate: start_date.value, + endDate: end_date.value + } + ); + } else { + promiseQuery = toolsLib.order.getAllUserTradesByKitId( + user_id.value, + symbol.value, + limit.value, + page.value, + order_by.value, + order.value, + start_date.value, + end_date.value, + format.value + ); + } } else { - promiseQuery = toolsLib.order.getAllTradesNetwork(symbol.value, limit.value, page.value, order_by.value, order.value, start_date.value, end_date.value, format.value); + if (format.value === 'all') { + promiseQuery = toolsLib.order.getAllTradesNetworkStream( + { + symbol: symbol.value, + limit: limit.value, + page: page.value, + orderBy: order_by.value, + order: order.value, + startDate: start_date.value, + endDate: end_date.value + } + ); + } else if (format.value === 'csv') { + promiseQuery = toolsLib.order.getAllTradesNetworkCsv( + { + symbol: symbol.value, + limit: limit.value, + page: page.value, + orderBy: order_by.value, + order: order.value, + startDate: start_date.value, + endDate: end_date.value + } + ); + } else { + promiseQuery = toolsLib.order.getAllTradesNetwork( + symbol.value, + limit.value, + page.value, + order_by.value, + order.value, + start_date.value, + end_date.value, + format.value + ); + } } promiseQuery .then((data) => { - if (format.value === 'csv') { - res.setHeader('Content-disposition', `attachment; filename=${toolsLib.getKitConfig().api_name}-users-trades.csv`); - res.set('Content-Type', 'text/csv'); - return res.status(202).send(data); - } else if (format.value === 'all') { - res.status(203); + if (format.value) { + if (format.value === 'csv') { + res.setHeader('Content-disposition', `attachment; filename=${user_id.value ? `user-${user_id.value}-` : ''}trades.csv`); + res.set('Content-Type', 'text/csv'); + res.status(202); + } data.pipe(res); } else { return res.json(data); From 10ec3e36d96cf25a30d7ce4e2875474c85832b36 Mon Sep 17 00:00:00 2001 From: brandonkimmmm Date: Fri, 9 Jul 2021 11:11:24 +0900 Subject: [PATCH 05/10] get trade stream update --- server/api/controllers/trade.js | 145 +++++++++++++++++++++++--------- 1 file changed, 106 insertions(+), 39 deletions(-) diff --git a/server/api/controllers/trade.js b/server/api/controllers/trade.js index e4c1a2e7d7..9fbaa959da 100644 --- a/server/api/controllers/trade.js +++ b/server/api/controllers/trade.js @@ -12,23 +12,84 @@ const getUserTrades = (req, res) => { ); const user_id = req.auth.sub.id; - const { limit, page, order_by, order, start_date, end_date, format } = req.swagger.params; + const { + limit, + page, + order_by, + order, + start_date, + end_date, + format + } = req.swagger.params; const symbol = req.swagger.params.symbol.value; + loggerTrades.info( + req.uuid, + 'controllers/trade/getUserTrades params', + 'user_id', + user_id, + 'symbol', + symbol, + 'limit', + limit.value, + 'page', + page.value, + 'order_by', + order_by.value, + 'order', + order.value, + 'start_date', + start_date.value, + 'end_date', + end_date.value, + 'format', + format.value + ); + if (symbol && !toolsLib.subscribedToPair(symbol)) { loggerTrades.error(req.uuid, 'controllers/trade/getUserTrades', 'Invalid symbol'); return res.status(400).json({ message: 'Invalid symbol' }); } - toolsLib.order.getAllUserTradesByKitId(user_id, symbol, limit.value, page.value, order_by.value, order.value, start_date.value, end_date.value, format.value) + let promiseQuery; + + if (format.value) { + promiseQuery = toolsLib.order[`getUserTradesByKitId${format.value === 'all' ? 'Stream' : 'Csv'}`]( + user_id, + { + symbol, + limit: limit.value, + page: page.value, + orderBy: order_by.value, + order: order.value, + startDate: start_date.value, + endDate: end_date.value + } + ); + } else { + promiseQuery = toolsLib.order.getAllUserTradesByKitId( + user_id, + symbol, + limit.value, + page.value, + order_by.value, + order.value, + start_date.value, + end_date.value + ); + } + + promiseQuery .then((data) => { - if (format.value === 'csv') { - res.setHeader('Content-disposition', `attachment; filename=${toolsLib.getKitConfig().api_name}-trades.csv`); - res.set('Content-Type', 'text/csv'); - return res.status(202).send(data); - } else if (format.value === 'all') { - res.status(203); - data.pipe(res); + if (format.value) { + if (format.value === 'csv') { + res.setHeader('Content-disposition', `attachment; filename=${toolsLib.getKitConfig().api_name}-trades.csv`); + res.set('Content-Type', 'text/csv'); + res.status(202); + } else { + res.status(203); + } + return data.pipe(res); } else { return res.json(data); } @@ -44,24 +105,39 @@ const getAdminTrades = (req, res) => { const { user_id, symbol, limit, page, order_by, order, start_date, end_date, format } = req.swagger.params; + loggerTrades.info( + req.uuid, + 'controllers/trade/getAdminTrades params', + 'user_id', + user_id.value, + 'symbol', + symbol.value, + 'limit', + limit.value, + 'page', + page.value, + 'order_by', + order_by.value, + 'order', + order.value, + 'start_date', + start_date.value, + 'end_date', + end_date.value, + 'format', + format.value + ); + + if (symbol.value && !toolsLib.subscribedToPair(symbol.value)) { + loggerTrades.error(req.uuid, 'controllers/trade/getUserTrades', 'Invalid symbol'); + return res.status(400).json({ message: 'Invalid symbol' }); + } + let promiseQuery; if (user_id.value) { - if (format.value === 'all') { - promiseQuery = toolsLib.order.getUserTradesByKitIdStream( - user_id.value, - { - symbol: symbol.value, - limit: limit.value, - page: page.value, - orderBy: order_by.value, - order: order.value, - startDate: start_date.value, - endDate: end_date.value - } - ); - } else if (format.value === 'csv') { - promiseQuery = toolsLib.order.getUserTradesByKitIdCsv( + if (format.value) { + promiseQuery = toolsLib.order[`getUserTradesByKitId${format.value === 'all' ? 'Stream' : 'Csv'}`]( user_id.value, { symbol: symbol.value, @@ -87,20 +163,9 @@ const getAdminTrades = (req, res) => { ); } } else { - if (format.value === 'all') { - promiseQuery = toolsLib.order.getAllTradesNetworkStream( - { - symbol: symbol.value, - limit: limit.value, - page: page.value, - orderBy: order_by.value, - order: order.value, - startDate: start_date.value, - endDate: end_date.value - } - ); - } else if (format.value === 'csv') { - promiseQuery = toolsLib.order.getAllTradesNetworkCsv( + if (format.value) { + promiseQuery = toolsLib.order[`getAllTradesNetwork${format.value === 'all' ? 'Stream' : 'Csv'}`]( + user_id.value, { symbol: symbol.value, limit: limit.value, @@ -132,8 +197,10 @@ const getAdminTrades = (req, res) => { res.setHeader('Content-disposition', `attachment; filename=${user_id.value ? `user-${user_id.value}-` : ''}trades.csv`); res.set('Content-Type', 'text/csv'); res.status(202); + } else { + res.status(203); } - data.pipe(res); + return data.pipe(res); } else { return res.json(data); } From f3d7e7aa895b1019ab7d6b51e4df9fe1f1513ad2 Mon Sep 17 00:00:00 2001 From: brandonkimmmm Date: Mon, 12 Jul 2021 13:19:48 +0900 Subject: [PATCH 06/10] get trade stream update for format all --- server/api/controllers/trade.js | 140 ++++++++++---------------------- server/api/swagger/swagger.yaml | 8 -- 2 files changed, 42 insertions(+), 106 deletions(-) diff --git a/server/api/controllers/trade.js b/server/api/controllers/trade.js index 9fbaa959da..03c1f0738b 100644 --- a/server/api/controllers/trade.js +++ b/server/api/controllers/trade.js @@ -51,45 +51,23 @@ const getUserTrades = (req, res) => { return res.status(400).json({ message: 'Invalid symbol' }); } - let promiseQuery; - - if (format.value) { - promiseQuery = toolsLib.order[`getUserTradesByKitId${format.value === 'all' ? 'Stream' : 'Csv'}`]( - user_id, - { - symbol, - limit: limit.value, - page: page.value, - orderBy: order_by.value, - order: order.value, - startDate: start_date.value, - endDate: end_date.value - } - ); - } else { - promiseQuery = toolsLib.order.getAllUserTradesByKitId( - user_id, - symbol, - limit.value, - page.value, - order_by.value, - order.value, - start_date.value, - end_date.value - ); - } - - promiseQuery + toolsLib.order.getAllUserTradesByKitId( + user_id, + symbol, + limit.value, + page.value, + order_by.value, + order.value, + start_date.value, + end_date.value, + format.value + ) .then((data) => { - if (format.value) { - if (format.value === 'csv') { - res.setHeader('Content-disposition', `attachment; filename=${toolsLib.getKitConfig().api_name}-trades.csv`); - res.set('Content-Type', 'text/csv'); - res.status(202); - } else { - res.status(203); - } - return data.pipe(res); + if (format.value == 'csv') { + res.setHeader('Content-disposition', `attachment; filename=${toolsLib.getKitConfig().api_name}-trades.csv`); + res.set('Content-Type', 'text/csv'); + res.status(202); + return res.send(data); } else { return res.json(data); } @@ -136,71 +114,37 @@ const getAdminTrades = (req, res) => { let promiseQuery; if (user_id.value) { - if (format.value) { - promiseQuery = toolsLib.order[`getUserTradesByKitId${format.value === 'all' ? 'Stream' : 'Csv'}`]( - user_id.value, - { - symbol: symbol.value, - limit: limit.value, - page: page.value, - orderBy: order_by.value, - order: order.value, - startDate: start_date.value, - endDate: end_date.value - } - ); - } else { - promiseQuery = toolsLib.order.getAllUserTradesByKitId( - user_id.value, - symbol.value, - limit.value, - page.value, - order_by.value, - order.value, - start_date.value, - end_date.value, - format.value - ); - } + promiseQuery = toolsLib.order.getAllUserTradesByKitId( + user_id.value, + symbol.value, + limit.value, + page.value, + order_by.value, + order.value, + start_date.value, + end_date.value, + format.value + ); } else { - if (format.value) { - promiseQuery = toolsLib.order[`getAllTradesNetwork${format.value === 'all' ? 'Stream' : 'Csv'}`]( - user_id.value, - { - symbol: symbol.value, - limit: limit.value, - page: page.value, - orderBy: order_by.value, - order: order.value, - startDate: start_date.value, - endDate: end_date.value - } - ); - } else { - promiseQuery = toolsLib.order.getAllTradesNetwork( - symbol.value, - limit.value, - page.value, - order_by.value, - order.value, - start_date.value, - end_date.value, - format.value - ); - } + promiseQuery = toolsLib.order.getAllTradesNetwork( + symbol.value, + limit.value, + page.value, + order_by.value, + order.value, + start_date.value, + end_date.value, + format.value + ); } promiseQuery .then((data) => { - if (format.value) { - if (format.value === 'csv') { - res.setHeader('Content-disposition', `attachment; filename=${user_id.value ? `user-${user_id.value}-` : ''}trades.csv`); - res.set('Content-Type', 'text/csv'); - res.status(202); - } else { - res.status(203); - } - return data.pipe(res); + if (format.value === 'csv') { + res.setHeader('Content-disposition', `attachment; filename=${user_id.value ? `user-${user_id.value}-` : ''}trades.csv`); + res.set('Content-Type', 'text/csv'); + res.status(202); + return res.send(data); } else { return res.json(data); } diff --git a/server/api/swagger/swagger.yaml b/server/api/swagger/swagger.yaml index b605977711..7a43c2a4ca 100644 --- a/server/api/swagger/swagger.yaml +++ b/server/api/swagger/swagger.yaml @@ -1617,10 +1617,6 @@ paths: description: CSV schema: type: string - 203: - description: Stream - schema: - type: string default: description: Error schema: @@ -3004,10 +3000,6 @@ paths: description: CSV schema: type: string - 203: - description: Stream - schema: - type: string default: description: Error schema: From fde563fd7e8307948350d6aa201f9862876551cf Mon Sep 17 00:00:00 2001 From: brandonkimmmm Date: Wed, 21 Jul 2021 12:44:14 +0900 Subject: [PATCH 07/10] tools, node lib version update --- server/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/package.json b/server/package.json index d57384472e..8655bd88c4 100644 --- a/server/package.json +++ b/server/package.json @@ -29,8 +29,8 @@ "flat": "5.0.0", "geoip-lite": "1.4.1", "helmet": "3.12.0", - "hollaex-node-lib": "github:bitholla/hollaex-node-lib#2.5", - "hollaex-tools-lib": "github:bitholla/hollaex-tools-lib#2.8", + "hollaex-node-lib": "github:bitholla/hollaex-node-lib#2.6", + "hollaex-tools-lib": "github:bitholla/hollaex-tools-lib#2.9", "http": "0.0.0", "install": "0.10.4", "json2csv": "4.5.4", From cc4d8b1dc5a66ec01f60916095b95b206122032f Mon Sep 17 00:00:00 2001 From: brandonkimmmm Date: Tue, 27 Jul 2021 17:27:35 +0900 Subject: [PATCH 08/10] same type plugin error message update --- server/plugins.js | 51 ++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/server/plugins.js b/server/plugins.js index 5c24093caa..e0df4304de 100644 --- a/server/plugins.js +++ b/server/plugins.js @@ -442,27 +442,29 @@ checkStatus() loggerPlugin.info(req.uuid, 'PUT /plugins name', name, 'version', version); - let sameTypePlugins = []; + let sameTypePlugin = null; if (type) { - sameTypePlugins = Plugin.findAll({ - where: { type } + sameTypePlugin = Plugin.findOne({ + where: { type }, + raw: true, + attributes: ['id', 'name', 'type'] }); } bluebird.all([ toolsLib.plugin.getPlugin(name), - sameTypePlugins + sameTypePlugin ]) - .then(([ plugin, sameType ]) => { + .then(([ plugin, sameTypePlugin ]) => { if (!plugin) { throw new Error('Plugin not installed'); } if (plugin.version === version) { throw new Error('Version is already installed'); } - if (sameType.length > 0 && type && plugin.type !== type) { - throw new Error(`Plugin with type ${type} already installed`); + if (sameTypePlugin && type && plugin.type !== type) { + throw new Error(`${name} version ${version} cannot be ran in parallel with an installed plugin (${sameTypePlugin.name}). Uninstall the plugin ${sameTypePlugin.name} before updating this plugin.`); } const updatedPlugin = { @@ -811,24 +813,31 @@ checkStatus() loggerPlugin.info(req.uuid, 'POST /plugins name', name, 'version', version); - const whereArray = [ - { name } - ]; + let sameTypePlugin = null; if (type) { - whereArray.push( - { type } - ); + sameTypePlugin = Plugin.findOne({ + where: { type }, + raw: true, + attributes: ['id', 'name', 'type'] + }); } - Plugin.findAll({ - where: { - [sequelize.Op.or]: whereArray - } - }) - .then((plugins) => { - if (plugins.length > 0) { - throw new Error('Plugin with same name or type is already installed'); + bluebird.all([ + Plugin.findOne({ + where: { name }, + raw: true, + attributes: ['id', 'name'] + }), + sameTypePlugin + ]) + .then(([ sameNamePlugin, sameTypePlugin ]) => { + if (sameNamePlugin) { + throw new Error(`Plugin ${name} is already installed`); + } + + if (sameTypePlugin) { + throw new Error(`${name} cannot be ran in parallel with an installed plugin (${sameTypePlugin.name}). Uninstall the plugin ${sameTypePlugin.name} before installing this plugin.`); } const newPlugin = { From 4784fef40da1cff783a9fa29051b8ad42209f44d Mon Sep 17 00:00:00 2001 From: brandonkimmmm Date: Wed, 28 Jul 2021 17:31:05 +0900 Subject: [PATCH 09/10] remove pagination for get /plugins --- server/plugins.js | 97 ++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 43 deletions(-) diff --git a/server/plugins.js b/server/plugins.js index e0df4304de..d25758ef51 100644 --- a/server/plugins.js +++ b/server/plugins.js @@ -125,18 +125,6 @@ checkStatus() }, optional: true }, - limit: { - in: ['query'], - errorMessage: 'must be an integer', - isInt: true, - optional: true - }, - page: { - in: ['query'], - errorMessage: 'must be an integer', - isInt: true, - optional: true - }, search: { in: ['query'], errorMessage: 'must be a string', @@ -154,48 +142,71 @@ checkStatus() return res.status(400).json({ errors: errors.array() }); } - const { limit, page, name, search } = req.query; + const { name, search } = req.query; - let promiseQuery = toolsLib.plugin.getPaginatedPlugins(limit, page, search); + let promiseQuery = null; if (name) { promiseQuery = toolsLib.plugin.getPlugin( name, { raw: true, - attributes: [ - 'name', - 'version', - 'enabled', - 'author', - 'description', - 'bio', - 'url', - 'logo', - 'icon', - 'documentation', - 'web_view', - 'public_meta', - 'type', - 'admin_view', - 'created_at', - 'updated_at' - ] + attributes: { + exclude: [ + 'id', + 'script', + 'meta', + 'prescript', + 'postscript' + ] + } } - ); - } - - promiseQuery - .then((plugins) => { - if (name) { - if (!plugins) { + ) + .then((data) => { + if (!data) { throw new Error('Plugin not found'); } else { - plugins.enabled_admin_view = !!plugins.admin_view; - delete plugins.admin_view; + data.enabled_admin_view = !!data.admin_view; + return lodash.omit(data, [ 'admin_view' ]); } - } - return res.json(plugins); + }); + } else { + const options = { + where: {}, + raw: true, + attributes: { + exclude: [ + 'id', + 'script', + 'meta', + 'prescript', + 'postscript' + ] + }, + order: [[ 'id', 'asc' ]] + }; + + if (search) { + options.where = { + name: { [sequelize.Op.like]: `%${search}%` } + }; + } + + promiseQuery = Plugin.findAndCountAll(options) + .then((data) => { + return { + count: data.count, + data: data.rows.map((plugin) => { + plugin.enabled_admin_view = !!plugin.admin_view; + return lodash.omit(plugin, [ 'admin_view' ]); + }) + }; + }); + } + + promiseQuery + .then((data) => { + return res.json(data); }) .catch((err) => { loggerPlugin.error(req.uuid, 'GET /plugins err', err.message); From f4d6b48b3c0a99cd8f6dd014cb6962885b2bc61b Mon Sep 17 00:00:00 2001 From: brandonkimmmm Date: Wed, 28 Jul 2021 17:46:30 +0900 Subject: [PATCH 10/10] type check for update plugin improvement --- server/plugins.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/plugins.js b/server/plugins.js index d25758ef51..60339f3735 100644 --- a/server/plugins.js +++ b/server/plugins.js @@ -457,7 +457,12 @@ checkStatus() if (type) { sameTypePlugin = Plugin.findOne({ - where: { type }, + where: { + type, + name: { + [sequelize.Op.not]: name + } + }, raw: true, attributes: ['id', 'name', 'type'] }); @@ -474,7 +479,7 @@ checkStatus() if (plugin.version === version) { throw new Error('Version is already installed'); } - if (sameTypePlugin && type && plugin.type !== type) { + if (sameTypePlugin) { throw new Error(`${name} version ${version} cannot be ran in parallel with an installed plugin (${sameTypePlugin.name}). Uninstall the plugin ${sameTypePlugin.name} before updating this plugin.`); }