Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jan 2, 2025
1 parent 8e3551c commit 5bd9567
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/app/extend/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
utils, Context as EggCoreContext, Router,
} from '@eggjs/core';
import type { Cookies as ContextCookies } from '@eggjs/cookies';
import { EggLogger } from 'egg-logger';
import type { EggLogger } from 'egg-logger';
import type { Application } from '../../lib/application.js';
import type {
HttpClientRequestURL, HttpClientRequestOptions, HttpClient,
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import Helper from './app/extend/helper.js';
// export extends
export {
Helper,
};
export type {
// keep compatible with egg v3
Helper as IHelper,
};
Expand All @@ -24,6 +26,7 @@ export * from './lib/error/index.js';
// export loggers
export type {
LoggerLevel,
EggLogger,
} from 'egg-logger';

// export httpClients
Expand Down
2 changes: 1 addition & 1 deletion src/lib/agent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EggLogger } from 'egg-logger';
import type { EggLogger } from 'egg-logger';
import { EggApplicationCore, EggApplicationCoreOptions } from './egg.js';
import { AgentWorkerLoader } from './loader/index.js';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/httpclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class HttpClient extends RawHttpClient {
}

// keep compatible
export {
export type {
HttpClient as EggHttpClient,
HttpClient as EggContextHttpClient,
};
Expand Down
5 changes: 2 additions & 3 deletions src/lib/egg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export type MiddlewareFunc<T extends Context = Context> = EggCoreMiddlewareFunc<
export {
Context,
Router,
EggLogger,
};

/**
Expand Down Expand Up @@ -664,8 +663,8 @@ export class EggApplicationCore extends EggCore {
* @param {Res} res - node native Response object
* @return {Context} context object
*/
createContext(req: IncomingMessage, res: ServerResponse): EggContext {
const context = Object.create(this.context) as EggContext;
createContext(req: IncomingMessage, res: ServerResponse): Context {
const context = Object.create(this.context) as Context;
const request = context.request = Object.create(this.request);
const response = context.response = Object.create(this.response);
context.app = request.app = response.app = this as any;
Expand Down
2 changes: 1 addition & 1 deletion test/app/middleware/meta.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('test/app/middleware/meta.test.ts', () => {
it('should get X-Readtime header', () => {
return app.httpRequest()
.get('/')
.expect('X-Readtime', /\d+/)
.expect('X-Readtime', /^\d+\.\d{1,3}$/)
.expect(200);
});
});
Expand Down
3 changes: 2 additions & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ describe('test/index.test.ts', () => {
'ClusterAgentWorkerError',
'ClusterWorkerExceptionError',
'Context',
'ContextHttpClient',
'Controller',
'CookieLimitExceedError',
'EggApplicationCore',
'EggLogger',
'Helper',
'HttpClient',
'Master',
'MessageUnhandledRejectionError',
'Request',
Expand Down
4 changes: 2 additions & 2 deletions test/lib/cluster/master.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('test/lib/cluster/master.test.ts', () => {
}

// wait for app worker restart
await scheduler.wait(5000);
await scheduler.wait(10000);

// error pipe to console
app.expect('stdout', /app_worker#1:\d+ disconnect/);
Expand All @@ -43,7 +43,7 @@ describe('test/lib/cluster/master.test.ts', () => {
}

// wait for app worker restart
await scheduler.wait(5000);
await scheduler.wait(10000);

app.expect('stderr', /\[graceful:worker:\d+:uncaughtException] throw error 1 times/);
app.expect('stdout', /app_worker#\d:\d+ started/);
Expand Down
4 changes: 4 additions & 0 deletions test/lib/egg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ describe('test/lib/egg.test.ts', () => {
});

describe('egg-ready', () => {
if (process.platform === 'win32') return;

let app: MockApplication;

before(() => {
Expand All @@ -472,6 +474,8 @@ describe('test/lib/egg.test.ts', () => {
});

describe('createAnonymousContext()', () => {
if (process.platform === 'win32') return;

let app: MockApplication;
before(() => {
app = createApp('apps/demo');
Expand Down
2 changes: 2 additions & 0 deletions test/lib/plugins/depd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { mm } from '@eggjs/mock';
import { MockApplication, createApp } from '../../utils.js';

describe('test/lib/plugins/depd.test.ts', () => {
if (process.platform === 'win32') return;

afterEach(mm.restore);

let app: MockApplication;
Expand Down

0 comments on commit 5bd9567

Please sign in to comment.