This commit is contained in:
Simon Larsen 2022-05-23 14:32:41 +01:00
parent 0dfa3d4b81
commit 8860559005
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
6 changed files with 18 additions and 10 deletions

View File

@ -0,0 +1,5 @@
import { JSONObject } from "../JSON";
export default interface EmptyResponseData extends JSONObject {
}

View File

@ -146,7 +146,7 @@ export default class BaseAPI<
const item: TBaseModel = BaseModel.fromJSON<TBaseModel>(
body['data'] as JSONObject
);
) as TBaseModel;
await this.service.updateByRole(oneuptimeRequest.role, {
query: {
@ -167,7 +167,7 @@ export default class BaseAPI<
const item: TBaseModel = BaseModel.fromJSON<TBaseModel>(
body['data'] as JSONObject
);
) as TBaseModel;
const savedItem: BaseModel = await this.service.createByRole(
oneuptimeRequest.role,

View File

@ -1,4 +1,5 @@
import HTTPResponse from 'Common/Types/API/Response';
import EmptyResponseData from 'Common/Types/API/EmptyResponse';
import HTTPResponse from 'Common/Types/API/HTTPResponse';
import Route from 'Common/Types/API/Route';
import URL from 'Common/Types/API/URL';
import Dictionary from 'Common/Types/Dictionary';
@ -19,7 +20,7 @@ export default class MailService {
projectId?: ObjectID;
forceSendFromGlobalMailServer?: boolean;
}
): Promise<HTTPResponse> {
): Promise<HTTPResponse<EmptyResponseData>> {
const body: JSONObject = {
toEmail: to.toString(),
subject,
@ -35,7 +36,7 @@ export default class MailService {
options.forceSendFromGlobalMailServer;
}
return await API.post(
return await API.post<EmptyResponseData>(
new URL(
HttpProtocol,
MailHostname,

View File

@ -4,7 +4,8 @@ import { JSONObjectOrArray } from 'Common/Types/JSON';
import Route from 'Common/Types/API/Route';
import Headers from 'Common/Types/API/Headers';
import ObjectID from 'Common/Types/ObjectID';
import HTTPResponse from 'Common/Types/API/Response';
import HTTPResponse from 'Common/Types/API/HTTPResponse';
import EmptyResponse from 'Common/Types/API/EmptyResponse';
class Service {
private api: API;
@ -21,8 +22,8 @@ class Service {
projectId: ObjectID,
eventType: string,
data: JSONObjectOrArray
): Promise<HTTPResponse> {
return await this.api.post(
): Promise<HTTPResponse<EmptyResponse>> {
return await this.api.post<EmptyResponse>(
new Route(`/send-created-incident`),
{
projectId,

View File

@ -13,6 +13,7 @@ import ListData from 'Common/Types/ListData';
import PositiveNumber from 'Common/Types/PositiveNumber';
import URL from 'Common/Types/API/URL';
import BaseModel from 'Common/Models/BaseModel';
import EmptyResponse from 'Common/Types/API/EmptyResponse';
export default class Response {
private static logResponse(
@ -64,7 +65,7 @@ export default class Response {
);
oneUptimeResponse.set('Pod-Id', process.env['POD_NAME']);
oneUptimeResponse.status(200).send();
oneUptimeResponse.status(200).send({} as EmptyResponse);
return this.logResponse(req, res, undefined);
}

View File

@ -3,7 +3,7 @@ import history from '../History';
import Headers from 'Common/Types/API/Headers';
import API from 'Common/Utils/API';
import APIException from 'Common/Types/Exception/ApiException';
import HTTPErrorResponse from 'Common/Types/API/ErrorResponse';
import HTTPErrorResponse from 'Common/Types/API/HTTPErrorResponse';
import Cookies from 'universal-cookie';
import Protocol from 'Common/Types/API/Protocol';
import Hostname from 'Common/Types/API/Hostname';