diff --git a/Accounts/Serve.ts b/Accounts/Serve.ts index d2f397cfb18..bf5a6f45184 100755 --- a/Accounts/Serve.ts +++ b/Accounts/Serve.ts @@ -1,5 +1,5 @@ import App from 'CommonServer/Utils/StartServer'; - +import { PromiseVoidFunction } from 'Common/Types/FunctionTypes'; import Express, { ExpressApplication } from 'CommonServer/Utils/Express'; import logger from 'CommonServer/Utils/Logger'; diff --git a/Accounts/src/Pages/VerifyEmail.tsx b/Accounts/src/Pages/VerifyEmail.tsx index 0024d6429d9..d0cb088535c 100644 --- a/Accounts/src/Pages/VerifyEmail.tsx +++ b/Accounts/src/Pages/VerifyEmail.tsx @@ -11,6 +11,7 @@ import Navigation from 'CommonUI/src/Utils/Navigation'; import ObjectID from 'Common/Types/ObjectID'; import URL from 'Common/Types/API/URL'; import API from 'CommonUI/src/Utils/API/API'; +import { PromiseVoidFunction } from 'Common/Types/FunctionTypes'; const VerifyEmail: () => JSX.Element = () => { const apiUrl: URL = VERIFY_EMAIL_API_URL; diff --git a/AdminDashboard/Serve.ts b/AdminDashboard/Serve.ts index d0e89c607f0..b69d12c4a6b 100755 --- a/AdminDashboard/Serve.ts +++ b/AdminDashboard/Serve.ts @@ -1,6 +1,7 @@ import App from 'CommonServer/Utils/StartServer'; import Express, { ExpressApplication } from 'CommonServer/Utils/Express'; import logger from 'CommonServer/Utils/Logger'; +import { PromiseVoidFunction } from 'Common/Types/FunctionTypes'; export const APP_NAME: string = 'admin'; diff --git a/AdminDashboard/src/Components/Footer/Footer.tsx b/AdminDashboard/src/Components/Footer/Footer.tsx index 954ac5e0d91..4b147d75575 100644 --- a/AdminDashboard/src/Components/Footer/Footer.tsx +++ b/AdminDashboard/src/Components/Footer/Footer.tsx @@ -8,6 +8,7 @@ import BadDataException from 'Common/Types/Exception/BadDataException'; import ConfirmModal from 'CommonUI/src/Components/Modal/ConfirmModal'; import Dictionary from 'Common/Types/Dictionary'; import HTTPResponse from 'Common/Types/API/HTTPResponse'; +import { PromiseVoidFunction } from 'Common/Types/FunctionTypes'; const DashboardFooter: () => JSX.Element = () => { const [showAboutModal, setShowAboutModal] = React.useState(false); diff --git a/AdminDashboard/src/Pages/Settings/SMTP/Index.tsx b/AdminDashboard/src/Pages/Settings/SMTP/Index.tsx index 988e5789e40..fd6d6058f06 100644 --- a/AdminDashboard/src/Pages/Settings/SMTP/Index.tsx +++ b/AdminDashboard/src/Pages/Settings/SMTP/Index.tsx @@ -16,6 +16,7 @@ import { JSONObject } from 'Common/Types/JSON'; import DropdownUtil from 'CommonUI/src/Utils/Dropdown'; import Pill from 'CommonUI/src/Components/Pill/Pill'; import { Green, Red } from 'Common/Types/BrandColors'; +import { PromiseVoidFunction } from 'Common/Types/FunctionTypes'; const Settings: FunctionComponent = (): ReactElement => { const [emailServerType, setemailServerType] = diff --git a/App/FeatureSet/Notification/API/Mail.ts b/App/FeatureSet/Notification/API/Mail.ts index 94ac9a90e20..6098cd72c16 100644 --- a/App/FeatureSet/Notification/API/Mail.ts +++ b/App/FeatureSet/Notification/API/Mail.ts @@ -48,7 +48,9 @@ router.post( } ); -const hasMailServerSettingsInBody: Function = (body: JSONObject): boolean => { +type HasMailServerSettingsInBody = (body: JSONObject) => boolean; + +const hasMailServerSettingsInBody: HasMailServerSettingsInBody = (body: JSONObject): boolean => { return ( body && Object.keys(body).filter((key: string) => { diff --git a/App/FeatureSet/Notification/Config.ts b/App/FeatureSet/Notification/Config.ts index 4fd2aa35495..b5c745f7a42 100644 --- a/App/FeatureSet/Notification/Config.ts +++ b/App/FeatureSet/Notification/Config.ts @@ -24,7 +24,9 @@ export const InternalSmtpEmail: Email = new Email( export const InternalSmtpFromName: string = process.env['INTERNAL_SMTP_FROM_NAME'] || 'OneUptime'; -export const getGlobalSMTPConfig: Function = +type GetGlobalSMTPConfig = () => Promise; + +export const getGlobalSMTPConfig: GetGlobalSMTPConfig = async (): Promise => { const globalConfig: GlobalConfig | null = await GlobalConfigService.findOneBy({ @@ -71,7 +73,9 @@ export const getGlobalSMTPConfig: Function = }; }; -export const getEmailServerType: Function = +type GetEmailServerTypeFunction = () => Promise; + +export const getEmailServerType: GetEmailServerTypeFunction = async (): Promise => { const globalConfig: GlobalConfig | null = await GlobalConfigService.findOneBy({ @@ -99,7 +103,9 @@ export interface SendGridConfig { fromEmail: Email; } -export const getSendgridConfig: Function = +type GetSendgridConfigFunction = () => Promise; + +export const getSendgridConfig: GetSendgridConfigFunction = async (): Promise => { const globalConfig: GlobalConfig | null = await GlobalConfigService.findOneBy({ @@ -135,7 +141,9 @@ export const getSendgridConfig: Function = return null; }; -export const getTwilioConfig: Function = + type GetTwilioConfigFunction = () => Promise; + +export const getTwilioConfig: GetTwilioConfigFunction = async (): Promise => { const globalConfig: GlobalConfig | null = await GlobalConfigService.findOneBy({ diff --git a/App/FeatureSet/Workers/Index.ts b/App/FeatureSet/Workers/Index.ts index eb80ee7637b..3d18aa111ed 100644 --- a/App/FeatureSet/Workers/Index.ts +++ b/App/FeatureSet/Workers/Index.ts @@ -73,6 +73,7 @@ import AnalyticsTableManagement from './Utils/AnalyticsDatabase/TableManegement' import './Jobs/Workflow/TimeoutJobs'; import './Jobs/MeteredPlan/ReportTelemetryMeteredPlan'; +import { PromiseVoidFunction } from 'Common/Types/FunctionTypes'; const APP_NAME: string = 'api/workers'; @@ -101,7 +102,7 @@ const WorkersFeatureSet: FeatureSet = { logger.info('Running Job: ' + name); - const funcToRun: Function = + const funcToRun: PromiseVoidFunction = JobDictionary.getJobFunction(name); if (funcToRun) { diff --git a/App/FeatureSet/Workers/Jobs/IncomingRequestMonitor/CheckHeartbeat.ts b/App/FeatureSet/Workers/Jobs/IncomingRequestMonitor/CheckHeartbeat.ts index a5a82789e00..bcfdee1f0c0 100644 --- a/App/FeatureSet/Workers/Jobs/IncomingRequestMonitor/CheckHeartbeat.ts +++ b/App/FeatureSet/Workers/Jobs/IncomingRequestMonitor/CheckHeartbeat.ts @@ -57,7 +57,9 @@ RunCron( } ); -const shouldProcessRequest: Function = (monitor: Monitor): boolean => { +type ShouldProcessRequestFunction = (monitor: Monitor) => boolean; + +const shouldProcessRequest: ShouldProcessRequestFunction = (monitor: Monitor): boolean => { // check if any criteria has request time step. If yes, then process the request. If no then skip the request. // We dont want Incoming Request Monitor to process the request if there is no criteria that checks for incoming request. // Those monitors criteria should be checked if the request is receievd from the API and not through the worker. diff --git a/App/FeatureSet/Workers/Utils/JobDictionary.ts b/App/FeatureSet/Workers/Utils/JobDictionary.ts index c9ecd4ea398..b9b84c92aed 100644 --- a/App/FeatureSet/Workers/Utils/JobDictionary.ts +++ b/App/FeatureSet/Workers/Utils/JobDictionary.ts @@ -1,18 +1,19 @@ import Dictionary from 'Common/Types/Dictionary'; import BadDataException from 'Common/Types/Exception/BadDataException'; +import { PromiseVoidFunction } from 'Common/Types/FunctionTypes'; export default class JobDictionary { - private static dictionary: Dictionary = {}; + private static dictionary: Dictionary = {}; - public static getJobFunction(name: string): Function { + public static getJobFunction(name: string): PromiseVoidFunction { if (this.dictionary[name]) { - return this.dictionary[name] as Function; + return this.dictionary[name] as PromiseVoidFunction; } throw new BadDataException('No job found with name: ' + name); } - public static setJobFunction(name: string, job: Function): void { + public static setJobFunction(name: string, job: PromiseVoidFunction): void { this.dictionary[name] = job; } }