From be02a2a608f6a0f5c053dd6ce597bf6698b31141 Mon Sep 17 00:00:00 2001 From: Nawaz Dhandala Date: Fri, 15 Apr 2022 11:49:06 +0100 Subject: [PATCH] fix --- Backend/api/CallRouting.ts | 12 ++++++++--- Backend/api/Search.ts | 21 ++++++++++++++----- Backend/test/emailAuthorization.test.ts | 2 +- Backend/test/enterpriseIncidentAlerts.test.ts | 2 +- Backend/test/incident.test.ts | 2 +- Backend/test/incidentAlerts.test.ts | 2 +- Backend/test/probe.test.ts | 2 +- Dashboard/src/components/basic/Socket.ts | 8 +++++-- .../src/cli/server-monitor/bin/index.ts | 6 +++--- JavaScriptSDK/test/logger.test.ts | 4 +++- JavaScriptSDK/test/tracker.test.ts | 4 +++- Probe/workers/kubernetesMonitors.ts | 10 ++++----- ScriptRunner/utils/bash.ts | 4 ++-- ScriptRunner/utils/scriptSandbox.ts | 5 +++-- StatusPage/index.ts | 2 +- 15 files changed, 56 insertions(+), 30 deletions(-) diff --git a/Backend/api/CallRouting.ts b/Backend/api/CallRouting.ts index 56ba457ca4..8ec4b025e9 100644 --- a/Backend/api/CallRouting.ts +++ b/Backend/api/CallRouting.ts @@ -20,7 +20,10 @@ const router: $TSFixMe = express.getRouter(); import multer from 'multer'; import storage from '../middlewares/upload'; -const callForward: Function = async (req: ExpressRequest, res: ExpressResponse): void => { +const callForward: Function = async ( + req: ExpressRequest, + res: ExpressResponse +): void => { try { const body: $TSFixMe = req.body; const to: $TSFixMe = body['To']; @@ -69,7 +72,10 @@ const backupCallForward: Function = async ( } }; -const callStatus: Function = async (req: ExpressRequest, res: ExpressResponse): void => { +const callStatus: Function = async ( + req: ExpressRequest, + res: ExpressResponse +): void => { try { const body: $TSFixMe = req.body; const to: $TSFixMe = body['To']; @@ -107,7 +113,7 @@ router.get( isAuthorized, async (req: ExpressRequest, res: ExpressResponse) => { try { - let {skip, limit}: $TSFixMe = req.query; + let { skip, limit }: $TSFixMe = req.query; const { projectId }: $TSFixMe = req.params; if (typeof skip === 'string') { diff --git a/Backend/api/Search.ts b/Backend/api/Search.ts index 71a8bbf162..4a2c84408a 100644 --- a/Backend/api/Search.ts +++ b/Backend/api/Search.ts @@ -249,7 +249,10 @@ const getStatusPages: Function = async ( return null; }; -const getUsers: Function = async (projectIds: $TSFixMe, val: $TSFixMe): void => { +const getUsers: Function = async ( + projectIds: $TSFixMe, + val: $TSFixMe +): void => { //get project users id so as to search for only users in a project and its subproject const projectUsers: $TSFixMe = []; @@ -260,7 +263,9 @@ const getUsers: Function = async (projectIds: $TSFixMe, val: $TSFixMe): void => projects.forEach((project: $TSFixMe) => { projectUsers.push(project.users); }); - const userIds: $TSFixMe = projectUsers.flat().map((user: $TSFixMe) => user.userId); + const userIds: $TSFixMe = projectUsers + .flat() + .map((user: $TSFixMe) => user.userId); const users: $TSFixMe = await UserService.findBy({ query: { _id: { $in: userIds }, @@ -466,7 +471,9 @@ const getErrorTrackers: Function = async ( query: { projectId: { $in: projectIds }, deleted: false }, select: '_id', }); - const componentIds: $TSFixMe = components.map((component: $TSFixMe) => component._id); + const componentIds: $TSFixMe = components.map( + (component: $TSFixMe) => component._id + ); const select: $TSFixMe = 'componentId name slug key showQuickStart resourceCategory createdById createdAt'; const populate: $TSFixMe = [ @@ -518,7 +525,9 @@ const getLogContainers: Function = async ( query: { projectId: { $in: projectIds }, deleted: false }, select: '_id', }); - const componentIds: $TSFixMe = components.map((component: $TSFixMe) => component._id); + const componentIds: $TSFixMe = components.map( + (component: $TSFixMe) => component._id + ); const populateAppLogs: $TSFixMe = [ { path: 'componentId', @@ -575,7 +584,9 @@ const getPerformanceTrackers: Function = async ( select: 'id', }); - const componentIds: $TSFixMe = components.map((component: $TSFixMe) => component._id); + const componentIds: $TSFixMe = components.map( + (component: $TSFixMe) => component._id + ); const selectPerfTracker: $TSFixMe = 'componentId name slug key showQuickStart createdById'; diff --git a/Backend/test/emailAuthorization.test.ts b/Backend/test/emailAuthorization.test.ts index 566aa99281..17fc5a21ae 100644 --- a/Backend/test/emailAuthorization.test.ts +++ b/Backend/test/emailAuthorization.test.ts @@ -18,7 +18,7 @@ import VerificationTokenModel from '../backend/models/verificationToken'; import AirtableService from '../backend/services/airtableService'; const sleep: Function = (waitTimeInMs: $TSFixMe): void => - new Promise((resolve: $TSFixMe) => setTimeout(resolve, waitTimeInMs)); + new Promise((resolve: $TSFixMe) => setTimeout(resolve, waitTimeInMs)); let userId: ObjectID, projectId: ObjectID; diff --git a/Backend/test/enterpriseIncidentAlerts.test.ts b/Backend/test/enterpriseIncidentAlerts.test.ts index a5de9308a2..21327272b5 100644 --- a/Backend/test/enterpriseIncidentAlerts.test.ts +++ b/Backend/test/enterpriseIncidentAlerts.test.ts @@ -39,7 +39,7 @@ import UserModel from '../backend/models/user'; import GlobalConfigModel from '../backend/models/globalConfig'; const sleep: Function = (waitTimeInMs: $TSFixMe): void => - new Promise((resolve: $TSFixMe) => setTimeout(resolve, waitTimeInMs)); + new Promise((resolve: $TSFixMe) => setTimeout(resolve, waitTimeInMs)); let authorization: $TSFixMe, token, diff --git a/Backend/test/incident.test.ts b/Backend/test/incident.test.ts index 50f252a370..dbe5912214 100644 --- a/Backend/test/incident.test.ts +++ b/Backend/test/incident.test.ts @@ -45,7 +45,7 @@ const selectEmailStatus: $TSFixMe = 'from to subject body createdAt template status content error deleted deletedAt deletedById replyTo smtpServer'; const sleep: Function = (waitTimeInMs: $TSFixMe): void => - new Promise((resolve: $TSFixMe) => setTimeout(resolve, waitTimeInMs)); + new Promise((resolve: $TSFixMe) => setTimeout(resolve, waitTimeInMs)); let token: $TSFixMe, userId: ObjectID, diff --git a/Backend/test/incidentAlerts.test.ts b/Backend/test/incidentAlerts.test.ts index 8a0cb65ab4..262dbce2c8 100644 --- a/Backend/test/incidentAlerts.test.ts +++ b/Backend/test/incidentAlerts.test.ts @@ -69,7 +69,7 @@ import uuid from 'uuid'; import axios from 'axios'; const sleep: Function = (waitTimeInMs: $TSFixMe): void => - new Promise((resolve: $TSFixMe) => setTimeout(resolve, waitTimeInMs)); + new Promise((resolve: $TSFixMe) => setTimeout(resolve, waitTimeInMs)); let authorization: $TSFixMe, userId: ObjectID, diff --git a/Backend/test/probe.test.ts b/Backend/test/probe.test.ts index fb65ce1b27..1b370c2aa8 100644 --- a/Backend/test/probe.test.ts +++ b/Backend/test/probe.test.ts @@ -32,7 +32,7 @@ import AirtableService from '../backend/services/airtableService'; let token: $TSFixMe, userId, projectId: ObjectID, componentId: $TSFixMe; const probeKey: string = 'test-key'; const sleep: Function = (waitTimeInMs: $TSFixMe): void => - new Promise((resolve: $TSFixMe) => setTimeout(resolve, waitTimeInMs)); + new Promise((resolve: $TSFixMe) => setTimeout(resolve, waitTimeInMs)); const generateRandomString: $TSFixMe = require('./utils/string').generateRandomString; const probeServerRequestHeader: Function = ({ diff --git a/Dashboard/src/components/basic/Socket.ts b/Dashboard/src/components/basic/Socket.ts index 79f2bc9b98..651192df79 100755 --- a/Dashboard/src/components/basic/Socket.ts +++ b/Dashboard/src/components/basic/Socket.ts @@ -535,7 +535,9 @@ class SocketApp extends Component { onClose: () => '', onConfirm: () => - new Promise((resolve: $TSFixMe) => resolve()), + new Promise((resolve: $TSFixMe) => + resolve() + ), content: RemovedFromProjectModal, }); } @@ -568,7 +570,9 @@ class SocketApp extends Component { onClose: () => '', onConfirm: () => - new Promise((resolve: $TSFixMe) => resolve()), + new Promise((resolve: $TSFixMe) => + resolve() + ), content: DataPathHoC( RemovedFromSubProjectModal, { diff --git a/JavaScriptSDK/src/cli/server-monitor/bin/index.ts b/JavaScriptSDK/src/cli/server-monitor/bin/index.ts index 2db8e8063b..0fe5a71475 100644 --- a/JavaScriptSDK/src/cli/server-monitor/bin/index.ts +++ b/JavaScriptSDK/src/cli/server-monitor/bin/index.ts @@ -86,7 +86,7 @@ const questions: $TSFixMe = [ const checkParams: Function = (params: $TSFixMe): void => { const values: $TSFixMe = []; - return new Promise((resolve: $TSFixMe) => { + return new Promise((resolve: $TSFixMe) => { resolve( params.reduce( (promiseChain, param) => @@ -112,7 +112,7 @@ const checkParams: Function = (params: $TSFixMe): void => { const getParamValue: Function = (params, name): void => { const options: $TSFixMe = program.opts(); - return new Promise((resolve: $TSFixMe) => { + return new Promise((resolve: $TSFixMe) => { if (options[name] === true || options[name] === undefined) { if (name === 'monitorId') { resolve(process.env[name] || null); @@ -259,7 +259,7 @@ checkParams(questions).then(values => { monitorId: monitorId || (data => { - return new Promise((resolve: $TSFixMe) => { + return new Promise((resolve: $TSFixMe) => { const question: $TSFixMe = questions.filter( param => param.name === 'monitorId' ); diff --git a/JavaScriptSDK/test/logger.test.ts b/JavaScriptSDK/test/logger.test.ts index 2ba35cdf0a..22b134b982 100644 --- a/JavaScriptSDK/test/logger.test.ts +++ b/JavaScriptSDK/test/logger.test.ts @@ -14,7 +14,9 @@ import OneUptimeLogger from '../src/logger'; describe('OneUptimeLogger', function (): void { const sleep: Function = (milliseconds: $TSFixMe): void => { - return new Promise((resolve: $TSFixMe) => setTimeout(resolve, milliseconds)); + return new Promise((resolve: $TSFixMe) => + setTimeout(resolve, milliseconds) + ); }; this.timeout(timeout + 1000); let projectId: ObjectID, diff --git a/JavaScriptSDK/test/tracker.test.ts b/JavaScriptSDK/test/tracker.test.ts index 101461d634..96a2310bde 100644 --- a/JavaScriptSDK/test/tracker.test.ts +++ b/JavaScriptSDK/test/tracker.test.ts @@ -23,7 +23,9 @@ let errorTracker: $TSFixMe; describe('Tracker Timeline', function (): void { const sleep: Function = (milliseconds: $TSFixMe): void => { - return new Promise((resolve: $TSFixMe) => setTimeout(resolve, milliseconds)); + return new Promise((resolve: $TSFixMe) => + setTimeout(resolve, milliseconds) + ); }; this.timeout(timeout + 1000); let projectId: ObjectID, token: $TSFixMe, componentId; diff --git a/Probe/workers/kubernetesMonitors.ts b/Probe/workers/kubernetesMonitors.ts index 33812e838e..6ac75a5532 100644 --- a/Probe/workers/kubernetesMonitors.ts +++ b/Probe/workers/kubernetesMonitors.ts @@ -658,7 +658,7 @@ export default { }; function loadPodOutput(configPath, namespace): void { - return new Promise((resolve: $TSFixMe) => { + return new Promise((resolve: $TSFixMe) => { let podOutput: $TSFixMe = ''; const podCommand: string = `kubectl get pods -o json --kubeconfig ${configPath} --namespace ${namespace}`; @@ -681,7 +681,7 @@ function loadPodOutput(configPath, namespace): void { } function loadJobOutput(configPath, namespace): void { - return new Promise((resolve: $TSFixMe) => { + return new Promise((resolve: $TSFixMe) => { let jobOutput: $TSFixMe = ''; const jobCommand: string = `kubectl get jobs -o json --kubeconfig ${configPath} --namespace ${namespace}`; @@ -704,7 +704,7 @@ function loadJobOutput(configPath, namespace): void { } function loadServiceOutput(configPath, namespace): void { - return new Promise((resolve: $TSFixMe) => { + return new Promise((resolve: $TSFixMe) => { let serviceOutput: $TSFixMe = ''; const serviceCommand: string = `kubectl get services -o json --kubeconfig ${configPath} --namespace ${namespace}`; @@ -727,7 +727,7 @@ function loadServiceOutput(configPath, namespace): void { } function loadDeploymentOutput(configPath, namespace): void { - return new Promise((resolve: $TSFixMe) => { + return new Promise((resolve: $TSFixMe) => { let deploymentOutput: $TSFixMe = ''; const deploymentCommand: string = `kubectl get deployments -o json --kubeconfig ${configPath} --namespace ${namespace}`; @@ -750,7 +750,7 @@ function loadDeploymentOutput(configPath, namespace): void { } function loadStatefulsetOutput(configPath, namespace): void { - return new Promise((resolve: $TSFixMe) => { + return new Promise((resolve: $TSFixMe) => { let statefulsetOutput: $TSFixMe = ''; const statefulsetCommand: string = `kubectl get statefulsets -o json --kubeconfig ${configPath} --namespace ${namespace}`; diff --git a/ScriptRunner/utils/bash.ts b/ScriptRunner/utils/bash.ts index 8bb6907145..b93380d327 100644 --- a/ScriptRunner/utils/bash.ts +++ b/ScriptRunner/utils/bash.ts @@ -3,8 +3,8 @@ import { performance } from 'perf_hooks'; const run: Function = async (script: $TSFixMe): void => { const start: $TSFixMe = performance.now(); - return new Promise((resolve: $TSFixMe) => { - exec(script, (err: $TSFixMe, stdout: $TSFixMe)=>{ + return new Promise((resolve: $TSFixMe) => { + exec(script, (err: $TSFixMe, stdout: $TSFixMe) => { if (err) { return resolve({ success: false, diff --git a/ScriptRunner/utils/scriptSandbox.ts b/ScriptRunner/utils/scriptSandbox.ts index 378588a173..f2ab88a9a2 100644 --- a/ScriptRunner/utils/scriptSandbox.ts +++ b/ScriptRunner/utils/scriptSandbox.ts @@ -16,7 +16,8 @@ class ScriptError extends Error { this.message = message; this.errors = Array.isArray(errors) ? errors.reduce( - (allErr: $TSFixMe, err: $TSFixMe) => [...allErr, err.message].join(','), + (allErr: $TSFixMe, err: $TSFixMe) => + [...allErr, err.message].join(','), [] ) : errors.message ?? errors; @@ -42,7 +43,7 @@ const run: Function = async ( return; } const start: $TSFixMe = performance.now(); - return new Promise((resolve: $TSFixMe) => { + return new Promise((resolve: $TSFixMe) => { const worker: $TSFixMe = new Worker(__filename, { workerData: { functionCode }, execArgv: [ diff --git a/StatusPage/index.ts b/StatusPage/index.ts index 18da114950..acc916b5cb 100755 --- a/StatusPage/index.ts +++ b/StatusPage/index.ts @@ -279,7 +279,7 @@ async function fetchCredential( } function decodeAndSave(content: $TSFixMe, filePath: $TSFixMe): void { - return new Promise((resolve: $TSFixMe) => { + return new Promise((resolve: $TSFixMe) => { const command: string = `echo ${content} | base64 -d`; let output: $TSFixMe = '';