From 8a249d354b99440d758dd616a87d5ac6b914730b Mon Sep 17 00:00:00 2001 From: Danilo Alonso Date: Sun, 9 Jun 2024 19:57:44 -0400 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=F0=9F=90=9B=20route=20payload=20opt?= =?UTF-8?q?ions=20missing=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🎟️ References #4505 #4501 --- lib/types/route.d.ts | 14 ++++++++------ lib/types/server/methods.d.ts | 2 ++ test/types/index.ts | 30 +++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/lib/types/route.d.ts b/lib/types/route.d.ts index 173964163..58dfa496b 100644 --- a/lib/types/route.d.ts +++ b/lib/types/route.d.ts @@ -255,6 +255,13 @@ export interface RouteOptionsPayload { */ maxBytes?: number | undefined; + /** + * @default 1000 + * Limits the size of incoming payloads to the specified byte count. Allowing very large payloads may cause the server to run out of memory. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadmaxparts) + */ + maxParts?: number; + /** * @default none. * Overrides payload processing for multipart requests. Value can be one of: @@ -267,12 +274,7 @@ export interface RouteOptionsPayload { * * * * payload - the processed part payload. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadmultipart) */ - multipart?: - | false - | { - output: PayloadOutput | 'annotated'; - } - | undefined; + multipart?: boolean | { output: PayloadOutput | 'annotated' }; /** * @default 'data'. diff --git a/lib/types/server/methods.d.ts b/lib/types/server/methods.d.ts index 9b54dcfce..dd482f988 100644 --- a/lib/types/server/methods.d.ts +++ b/lib/types/server/methods.d.ts @@ -17,6 +17,8 @@ export type ServerMethod = (...args: any[]) => any; */ export interface ServerMethodCache extends PolicyOptions { generateTimeout: number | false; + cache?: string; + segment?: string; } /** diff --git a/test/types/index.ts b/test/types/index.ts index e6a824b6b..988edffb0 100644 --- a/test/types/index.ts +++ b/test/types/index.ts @@ -1,5 +1,6 @@ import { types as lab } from '@hapi/lab'; import { expect } from '@hapi/code'; +import * as CatboxMemory from '@hapi/catbox-memory'; import { Plugin, @@ -39,11 +40,17 @@ interface RequestDecorations { type AppRequest = Request; const route: ServerRoute = { - method: 'GET', + method: 'POST', path: '/', options: { app: { prefix: ['xx-'] + }, + payload: { + maxParts: 100, + maxBytes: 1024 * 1024, + output: 'stream', + multipart: true } }, handler: (request: AppRequest, h: ResponseToolkit) => { @@ -96,3 +103,24 @@ check.type(server.match('get', '/')); const sum = loadedServer.plugins.test.add(1, 2); expect(sum).to.equal(130); check.type(sum); + +server.cache.provision({ + name: 'some-cache', + provider: { + constructor: CatboxMemory.Engine, + options: { + partition: 'test' + } + } +}) + +server.method('test.add', (a: number, b: number) => a + b, { + bind: server, + cache: { + expiresIn: 1000, + generateTimeout: 100, + cache: 'some-cache', + segment: 'test-segment', + }, + generateKey: (a: number, b: number) => `${a}${b}` +}); \ No newline at end of file From 236d02ffaf07cddf74568b041996833bf7710f1d Mon Sep 17 00:00:00 2001 From: Danilo Alonso Date: Mon, 10 Jun 2024 10:31:51 -0400 Subject: [PATCH 2/3] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20maxParts=20jsd?= =?UTF-8?q?oc=20description?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/types/route.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/types/route.d.ts b/lib/types/route.d.ts index 58dfa496b..be2416850 100644 --- a/lib/types/route.d.ts +++ b/lib/types/route.d.ts @@ -257,7 +257,7 @@ export interface RouteOptionsPayload { /** * @default 1000 - * Limits the size of incoming payloads to the specified byte count. Allowing very large payloads may cause the server to run out of memory. + * Limits the number of parts allowed in multipart payloads. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadmaxparts) */ maxParts?: number; From 15ff0dd286bb5a81877a4f2cca72d585f609a865 Mon Sep 17 00:00:00 2001 From: Nicolas Morel Date: Wed, 12 Jun 2024 09:58:13 +0200 Subject: [PATCH 3/3] chore: bump catbox-memory --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7d582b913..43ed22394 100755 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@hapi/bounce": "^3.0.1", "@hapi/call": "^9.0.1", "@hapi/catbox": "^12.1.1", - "@hapi/catbox-memory": "^6.0.1", + "@hapi/catbox-memory": "^6.0.2", "@hapi/heavy": "^8.0.1", "@hapi/hoek": "^11.0.2", "@hapi/mimos": "^7.0.1",