Skip to content

Commit

Permalink
export EggAppInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jan 3, 2025
1 parent 8e1a12e commit 25c6528
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 24 deletions.
24 changes: 0 additions & 24 deletions index-old.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,30 +218,6 @@

// export type LoggerLevel = EggLoggerLevel;


// /**
// * egg app info
// * @example
// * ```js
// * // config/config.default.ts
// * import { EggAppInfo } from 'egg';
// *
// * export default (appInfo: EggAppInfo) => {
// * return {
// * keys: appInfo.name + '123456',
// * };
// * }
// * ```
// */
// export interface EggAppInfo {
// pkg: any; // package.json
// name: string; // the application name from package.json
// baseDir: string; // current directory of application
// env: EggEnvType; // equals to serverEnv
// HOME: string; // home directory of the OS
// root: string; // baseDir when local and unittest, HOME when other environment
// }

// type IgnoreItem = string | RegExp | ((ctx: Context) => boolean);
// type IgnoreOrMatch = IgnoreItem | IgnoreItem[];

Expand Down
2 changes: 2 additions & 0 deletions src/app/extend/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const HOST = Symbol('request host');
const IPS = Symbol('request ips');
const RE_ARRAY_KEY = /[^\[\]]+\[\]$/;

import './request.types.js';

export default class Request extends EggCoreRequest {
declare app: Application;
declare ctx: Context;
Expand Down
2 changes: 2 additions & 0 deletions src/app/extend/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Response as KoaResponse } from '@eggjs/core';

const REAL_STATUS = Symbol('response realStatus');

import './response.types.js';

export default class Response extends KoaResponse {
/**
* Get or set a real status code.
Expand Down
5 changes: 5 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import type { SiteFileMiddlewareOptions } from '../app/middleware/site_file.js';
// import @eggjs/watcher types
// import '@eggjs/watcher';

export type {
EggAppInfo,
} from '@eggjs/core';


type IgnoreItem = string | RegExp | ((ctx: Context) => boolean);
type IgnoreOrMatch = IgnoreItem | IgnoreItem[];

Expand Down
11 changes: 11 additions & 0 deletions test/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Context, Application, IBoot, ILifecycleBoot,
LoggerLevel,
EggPlugin,
EggAppInfo,
} from '../src/index.js';
import { HttpClient } from '../src/urllib.js';

Expand Down Expand Up @@ -98,3 +99,13 @@ const plugin: EggPlugin = {
logrotator: true,
};
expectType<EggPlugin>(plugin);

expectType<EggAppInfo>({
name: 'egg',
baseDir: 'baseDir',
env: 'env',
HOME: 'HOME',
pkg: {},
scope: 'scope',
root: 'root',
});

0 comments on commit 25c6528

Please sign in to comment.