From 45b706d7d5d6e2ae6694f6c9f36330b20d46c9e8 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Tue, 27 Feb 2024 12:28:24 +0000 Subject: [PATCH] Add ExpressAPIFunctionType to processIncomingRequest and returnResponse --- Common/Types/FunctionTypes.ts | 1 + CommonServer/Types/FunctionTypes.ts | 7 +++++++ Ingestor/API/IncomingRequest.ts | 3 ++- TestServer/API/Main.ts | 3 ++- 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 CommonServer/Types/FunctionTypes.ts diff --git a/Common/Types/FunctionTypes.ts b/Common/Types/FunctionTypes.ts index e69de29bb2..cfdd1a7331 100644 --- a/Common/Types/FunctionTypes.ts +++ b/Common/Types/FunctionTypes.ts @@ -0,0 +1 @@ +export type PromiseVoidFunctionType = () => Promise; \ No newline at end of file diff --git a/CommonServer/Types/FunctionTypes.ts b/CommonServer/Types/FunctionTypes.ts new file mode 100644 index 0000000000..b178017ffd --- /dev/null +++ b/CommonServer/Types/FunctionTypes.ts @@ -0,0 +1,7 @@ +import { ExpressRequest, ExpressResponse, NextFunction } from "../Utils/Express"; + +export type ExpressAPIFunctionType = ( + req: ExpressRequest, + res: ExpressResponse, + next: NextFunction +) => Promise; \ No newline at end of file diff --git a/Ingestor/API/IncomingRequest.ts b/Ingestor/API/IncomingRequest.ts index 9e68e4bd36..000b4cf0b4 100644 --- a/Ingestor/API/IncomingRequest.ts +++ b/Ingestor/API/IncomingRequest.ts @@ -12,10 +12,11 @@ import { JSONObject } from 'Common/Types/JSON'; import ObjectID from 'Common/Types/ObjectID'; import IncomingMonitorRequest from 'Common/Types/Monitor/IncomingMonitor/IncomingMonitorRequest'; import OneUptimeDate from 'Common/Types/Date'; +import {ExpressAPIFunctionType} from 'CommonServer/Types/FunctionTypes'; const router: ExpressRouter = Express.getRouter(); -const processIncomingRequest: Function = async ( +const processIncomingRequest: ExpressAPIFunctionType = async ( req: ExpressRequest, res: ExpressResponse, next: NextFunction diff --git a/TestServer/API/Main.ts b/TestServer/API/Main.ts index e0e6510afc..bfeee29969 100644 --- a/TestServer/API/Main.ts +++ b/TestServer/API/Main.ts @@ -10,6 +10,7 @@ import Sleep from 'Common/Types/Sleep'; import Typeof from 'Common/Types/Typeof'; import { JSONValue } from 'Common/Types/JSON'; import logger from 'CommonServer/Utils/Logger'; +import {ExpressAPIFunctionType} from 'CommonServer/Types/FunctionTypes'; const router: ExpressRouter = Express.getRouter(); @@ -35,7 +36,7 @@ router.post( } ); -const returnResponse: Function = async ( +const returnResponse: ExpressAPIFunctionType = async ( req: ExpressRequest, res: ExpressResponse, next: NextFunction