Skip to content

Commit

Permalink
fix: add allowH2 define and more (#5392)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## 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.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
fengmk2 authored Feb 4, 2025
1 parent a8de7bf commit 413a6f9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/extend/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>, taskName?: string): void;
_runInBackground(scope: (ctx: Context) => Promise<void>, taskName: string): void;
get acceptJSON(): boolean;
get query(): Record<string, string>;
get queries(): Record<string, string[]>;
curl(url: HttpClientRequestURL, options?: HttpClientRequestOptions): ReturnType<HttpClient['request']>;
get router(): Router;
set router(val: Router);
Expand Down
4 changes: 4 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ export interface HttpClientConfig {
* @deprecated keep compatible with egg 3.x, no more used
*/
useHttpClientNext?: boolean;
/**
* Allow http2
*/
allowH2?: boolean;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions test/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ class AppBoot implements ILifecycleBoot {
}

const app1 = {} as Application;

expectType<boolean>(app1.config.httpclient.allowH2!);

const appBoot = new AppBoot(app1);
expectType<IBoot>(appBoot);
expectType<ILifecycleBoot>(appBoot);
Expand Down

0 comments on commit 413a6f9

Please sign in to comment.