From ff8489f94c659f514954eb9bf81d028ef3fea93f Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Mon, 14 Dec 2020 14:44:48 +0100 Subject: [PATCH] Address TODOs --- src/core/server/http/http_server.test.ts | 4 ++-- src/core/server/http/http_server.ts | 4 ++-- src/core/server/http/router/response_adapter.ts | 2 +- .../saved_objects/export/get_sorted_objects_for_export.ts | 2 +- src/core/server/saved_objects/import/validate_references.ts | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/server/http/http_server.test.ts b/src/core/server/http/http_server.test.ts index 4c697d22b6565..739a146c6dcc5 100644 --- a/src/core/server/http/http_server.test.ts +++ b/src/core/server/http/http_server.test.ts @@ -1166,7 +1166,7 @@ describe('timeout options', () => { router.get( { path: '/', - validate: false, // TODO: Figure out if we can/should use `{ body: schema.any() }` instead + validate: { body: schema.maybe(schema.any()) }, }, (context, req, res) => { return res.ok({ @@ -1199,7 +1199,7 @@ describe('timeout options', () => { router.get( { path: '/', - validate: false, // TODO: Figure out if we can/should use `{ body: schema.any() }` instead + validate: { body: schema.maybe(schema.any()) }, options: { timeout: { idleSocket: 12000 } }, }, (context, req, res) => { diff --git a/src/core/server/http/http_server.ts b/src/core/server/http/http_server.ts index d6ab306171d12..42e89b66d9c51 100644 --- a/src/core/server/http/http_server.ts +++ b/src/core/server/http/http_server.ts @@ -190,11 +190,11 @@ export class HttpServer { output, parse, timeout: timeout?.payload, - multipart: true, // TODO: Figure out what the default value should be + multipart: true, } : undefined, timeout: { - socket: timeout?.idleSocket ?? this.config!.socketTimeout ?? false, // TODO: Do we really want to fall back to NO timeout? Shouldn't we default to the default Node.js timeout of 2 minutes? + socket: timeout?.idleSocket ?? this.config!.socketTimeout, }, }, }; diff --git a/src/core/server/http/router/response_adapter.ts b/src/core/server/http/router/response_adapter.ts index 32dfb36fd91ef..beeab5c05e816 100644 --- a/src/core/server/http/router/response_adapter.ts +++ b/src/core/server/http/router/response_adapter.ts @@ -137,7 +137,7 @@ export class HapiResponseAdapter { const attributes = getErrorAttributes(payload); if (attributes) { - // @ts-expect-error `attributes` does not exist on the `Payload` type, however it does exist in real life (https://github.com/hapijs/boom/issues/277) + // @ts-expect-error Custom properties on `output.payload` aren't allowed by TS, however, it's the only way to send custom data to the client (https://github.com/hapijs/boom/issues/277). error.output.payload.attributes = attributes; } diff --git a/src/core/server/saved_objects/export/get_sorted_objects_for_export.ts b/src/core/server/saved_objects/export/get_sorted_objects_for_export.ts index 92822a7eca83e..1e6e8b213640a 100644 --- a/src/core/server/saved_objects/export/get_sorted_objects_for_export.ts +++ b/src/core/server/saved_objects/export/get_sorted_objects_for_export.ts @@ -154,7 +154,7 @@ async function fetchByObjects({ const erroredObjects = bulkGetResult.saved_objects.filter((obj) => !!obj.error); if (erroredObjects.length) { const err = Boom.badRequest(); - // @ts-expect-error `attributes` does not exist on the `Payload` type, however it does exist in real life (https://github.com/hapijs/boom/issues/277) + // @ts-expect-error Custom properties on `output.payload` aren't allowed by TS, however, it's the only way to send custom data to the client (https://github.com/hapijs/boom/issues/277). err.output.payload.attributes = { objects: erroredObjects, }; diff --git a/src/core/server/saved_objects/import/validate_references.ts b/src/core/server/saved_objects/import/validate_references.ts index 925782ee7c71b..f58a9afcfd4ac 100644 --- a/src/core/server/saved_objects/import/validate_references.ts +++ b/src/core/server/saved_objects/import/validate_references.ts @@ -71,7 +71,7 @@ export async function getNonExistingReferenceAsKeys( ); if (erroredObjects.length) { const err = Boom.badRequest(); - // @ts-expect-error `attributes` does not exist on the `Payload` type, however it does exist in real life (https://github.com/hapijs/boom/issues/277) + // @ts-expect-error Custom properties on `output.payload` aren't allowed by TS, however, it's the only way to send custom data to the client (https://github.com/hapijs/boom/issues/277). err.output.payload.attributes = { objects: erroredObjects, };