From 413a6f905161bc45ae54baccc83ae82170fecd09 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Tue, 4 Feb 2025 20:47:21 +0800 Subject: [PATCH] fix: add allowH2 define and more (#5392) ## Summary by CodeRabbit - **New Features** - Enhanced background processing with improved asynchronous task handling and performance tracking, contributing to a more responsive experience. - Introduced an optional configuration for HTTP/2 support, enabling more efficient network communications. --- src/app/extend/context.ts | 8 ++++++++ src/lib/types.ts | 4 ++++ test/index.test-d.ts | 3 +++ 3 files changed, 15 insertions(+) diff --git a/src/app/extend/context.ts b/src/app/extend/context.ts index 27a0a7cd2b..3199ed604d 100644 --- a/src/app/extend/context.ts +++ b/src/app/extend/context.ts @@ -308,6 +308,14 @@ export default class Context extends EggCoreContext { declare module '@eggjs/core' { // add Context overrides types interface Context { + proxy: any; + performanceStarttime: number; + starttime: number; + runInBackground(scope: (ctx: Context) => Promise, taskName?: string): void; + _runInBackground(scope: (ctx: Context) => Promise, taskName: string): void; + get acceptJSON(): boolean; + get query(): Record; + get queries(): Record; curl(url: HttpClientRequestURL, options?: HttpClientRequestOptions): ReturnType; get router(): Router; set router(val: Router); diff --git a/src/lib/types.ts b/src/lib/types.ts index 82c925c04b..5f97e6ee55 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -81,6 +81,10 @@ export interface HttpClientConfig { * @deprecated keep compatible with egg 3.x, no more used */ useHttpClientNext?: boolean; + /** + * Allow http2 + */ + allowH2?: boolean; } /** diff --git a/test/index.test-d.ts b/test/index.test-d.ts index 9f5ffee717..59bc82e5d2 100644 --- a/test/index.test-d.ts +++ b/test/index.test-d.ts @@ -146,6 +146,9 @@ class AppBoot implements ILifecycleBoot { } const app1 = {} as Application; + +expectType(app1.config.httpclient.allowH2!); + const appBoot = new AppBoot(app1); expectType(appBoot); expectType(appBoot);