From 847cacb16bcf18ed830fcef940914310cb78ac65 Mon Sep 17 00:00:00 2001 From: VallariAg Date: Tue, 16 Nov 2021 03:34:32 +0530 Subject: [PATCH 1/2] Move constants to provider files --- dashboard/server/api/runApi.js | 18 +++++++--------- dashboard/server/index.js | 38 ++++++++++++++++------------------ 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/dashboard/server/api/runApi.js b/dashboard/server/api/runApi.js index 5c6f3f8..a00a97b 100644 --- a/dashboard/server/api/runApi.js +++ b/dashboard/server/api/runApi.js @@ -1,13 +1,11 @@ -const { - FRONTEND_ABORT_RUN, - FRONTEND_NEW_RUN, - FRONTEND_PAUSE_RUN, - FRONTEND_RESUME_RUN, - FRONTEND_RUN_EVENT, - FRONTEND_DONE_RUN, - FRONTEND_INTERRUPT_RUN, - FRONTEND_RUN_STATS, -} = require('../../lib/constants/frontend-events'); +const FRONTEND_NEW_RUN = 'start'; +const FRONTEND_PAUSE_RUN = 'pause'; +const FRONTEND_ABORT_RUN = 'abort'; +const FRONTEND_RESUME_RUN = 'resume'; +const FRONTEND_DONE_RUN = 'done'; +const FRONTEND_INTERRUPT_RUN = 'interrupt'; +const FRONTEND_RUN_EVENT = 'run-event'; +const FRONTEND_RUN_STATS = 'run-stats'; const controllers = require('../../lib/controllers/run'); diff --git a/dashboard/server/index.js b/dashboard/server/index.js index a782835..c59fdf9 100644 --- a/dashboard/server/index.js +++ b/dashboard/server/index.js @@ -6,26 +6,24 @@ const runHandlers = require('./api/runApi'); const frontendHandlers = require('./api/frontendApi'); const utils = require('../lib/utils'); -const { - START_RUN, - PAUSE_RUN, - ABORT_RUN, - RESUME_RUN, - DONE_RUN, - INTERRUPT_RUN, - TEST_CONN, - RUN_EVENT, - RUN_STATS, -} = require('../lib/constants/socket-events'); -const { NEWMAN_RUN, FRONTEND } = require('../lib/constants/socket-rooms'); - -const { - FRONTEND_REQUEST_ABORT, - FRONTEND_REQUEST_RESUME, - FRONTEND_REQUEST_PAUSE, - FRONTEND_REQUEST_TEST_CONN, - FRONTEND_REQUEST_TERMINATE, -} = require('../lib/constants/frontend-events'); +const START_RUN = 'start'; +const PAUSE_RUN = 'pause'; +const ABORT_RUN = 'abort'; +const RESUME_RUN = 'resume'; +const DONE_RUN = 'done'; +const INTERRUPT_RUN = 'interrupt'; +const RUN_EVENT = 'run-event'; +const RUN_STATS = 'run-stats'; +const TEST_CONN = 'test'; + +const NEWMAN_RUN = 'newman-run'; +const FRONTEND = 'frontend'; + +const FRONTEND_REQUEST_PAUSE = 'pause'; +const FRONTEND_REQUEST_ABORT = 'abort'; +const FRONTEND_REQUEST_RESUME = 'resume'; +const FRONTEND_REQUEST_TERMINATE = 'terminate'; +const FRONTEND_REQUEST_TEST_CONN = 'test'; const init = () => { // setup socket.io server From e237b7b418709340c3dddcd44034cbf6c836bebf Mon Sep 17 00:00:00 2001 From: VallariAg Date: Tue, 16 Nov 2021 03:49:13 +0530 Subject: [PATCH 2/2] Remove /constants files --- dashboard/lib/constants/frontend-events.js | 16 ---------------- dashboard/lib/constants/socket-events.js | 15 --------------- dashboard/lib/constants/socket-rooms.js | 4 ---- dashboard/server/api/frontendApi.js | 8 +++----- 4 files changed, 3 insertions(+), 40 deletions(-) delete mode 100644 dashboard/lib/constants/frontend-events.js delete mode 100644 dashboard/lib/constants/socket-events.js delete mode 100644 dashboard/lib/constants/socket-rooms.js diff --git a/dashboard/lib/constants/frontend-events.js b/dashboard/lib/constants/frontend-events.js deleted file mode 100644 index 7533e49..0000000 --- a/dashboard/lib/constants/frontend-events.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - FRONTEND_NEW_RUN: 'start', - FRONTEND_PAUSE_RUN: 'pause', - FRONTEND_ABORT_RUN: 'abort', - FRONTEND_RESUME_RUN: 'resume', - FRONTEND_DONE_RUN: 'done', - FRONTEND_INTERRUPT_RUN: 'interrupt', - FRONTEND_RUN_EVENT: 'run-event', - FRONTEND_RUN_STATS: 'run-stats', - - FRONTEND_REQUEST_PAUSE: 'pause', - FRONTEND_REQUEST_ABORT: 'abort', - FRONTEND_REQUEST_RESUME: 'resume', - FRONTEND_REQUEST_TERMINATE: 'terminate', - FRONTEND_REQUEST_TEST_CONN: 'test', -}; diff --git a/dashboard/lib/constants/socket-events.js b/dashboard/lib/constants/socket-events.js deleted file mode 100644 index df647b1..0000000 --- a/dashboard/lib/constants/socket-events.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - START_RUN: 'start', - PAUSE_RUN: 'pause', - ABORT_RUN: 'abort', - RESUME_RUN: 'resume', - DONE_RUN: 'done', - INTERRUPT_RUN: 'interrupt', - RUN_EVENT: 'run-event', - RUN_STATS: 'run-stats', - TEST_CONN: 'test', - - PAUSE_REQUEST: 'pause', - ABORT_REQUEST: 'abort', - RESUME_REQUEST: 'resume', -}; diff --git a/dashboard/lib/constants/socket-rooms.js b/dashboard/lib/constants/socket-rooms.js deleted file mode 100644 index 11c69ad..0000000 --- a/dashboard/lib/constants/socket-rooms.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - NEWMAN_RUN: 'newman-run', - FRONTEND: 'frontend', -}; diff --git a/dashboard/server/api/frontendApi.js b/dashboard/server/api/frontendApi.js index 0635d86..d88e742 100644 --- a/dashboard/server/api/frontendApi.js +++ b/dashboard/server/api/frontendApi.js @@ -1,8 +1,6 @@ -const { - ABORT_REQUEST, - PAUSE_REQUEST, - RESUME_REQUEST, -} = require('../../lib/constants/socket-events'); +const PAUSE_REQUEST = 'pause'; +const ABORT_REQUEST = 'abort'; +const RESUME_REQUEST = 'resume'; module.exports = (socket) => ({ handlePauseRequest: (data, callback) => {