Skip to content

Commit 8e1a12e

Browse files
committed
export EggPlugin
1 parent 5bd9567 commit 8e1a12e

9 files changed

Lines changed: 69 additions & 40 deletions

File tree

index-old.d.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,40 +1082,6 @@
10821082
// urlFor(name: string, params?: PlainObject): string;
10831083
// }
10841084

1085-
// // egg env type
1086-
// export type EggEnvType = 'local' | 'unittest' | 'prod' | string;
1087-
1088-
// /**
1089-
// * plugin config item interface
1090-
// */
1091-
// export interface IEggPluginItem {
1092-
// env?: EggEnvType[];
1093-
// path?: string;
1094-
// package?: string;
1095-
// enable?: boolean;
1096-
// }
1097-
1098-
// export type EggPluginItem = IEggPluginItem | boolean;
1099-
1100-
// /**
1101-
// * build-in plugin list
1102-
// */
1103-
// export interface EggPlugin {
1104-
// [key: string]: EggPluginItem | undefined;
1105-
// onerror?: EggPluginItem;
1106-
// session?: EggPluginItem;
1107-
// i18n?: EggPluginItem;
1108-
// watcher?: EggPluginItem;
1109-
// multipart?: EggPluginItem;
1110-
// security?: EggPluginItem;
1111-
// development?: EggPluginItem;
1112-
// logrotator?: EggPluginItem;
1113-
// schedule?: EggPluginItem;
1114-
// static?: EggPluginItem;
1115-
// jsonp?: EggPluginItem;
1116-
// view?: EggPluginItem;
1117-
// }
1118-
11191085
// /**
11201086
// * Singleton instance in Agent Worker, extend {@link EggApplication}
11211087
// */

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "egg",
3-
"version": "4.0.0-beta.12",
3+
"version": "4.0.0-beta.13",
44
"engines": {
55
"node": ">= 18.19.0"
66
},

src/config/config.default.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path';
22
import { pathToFileURL } from 'node:url';
33
import type { EggAppInfo } from '@eggjs/core';
4-
import type { EggAppConfig } from '../lib/type.js';
4+
import type { EggAppConfig } from '../lib/types.js';
55
import { getSourceFile } from '../lib/utils.js';
66

77
/**

src/config/config.local.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { EggAppConfig } from '../lib/type.js';
1+
import type { EggAppConfig } from '../lib/types.js';
22

33
export default () => {
44
return {

src/config/config.unittest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { EggAppConfig } from '../lib/type.js';
1+
import type { EggAppConfig } from '../lib/types.js';
22

33
export default () => {
44
return {

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type {
1717

1818
// export types
1919
export * from './lib/egg.js';
20-
export * from './lib/type.js';
20+
export * from './lib/types.js';
2121
export * from './lib/start.js';
2222

2323
// export errors

src/lib/egg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import CircularJSON from 'circular-json-for-egg';
2727
import type { Agent } from './agent.js';
2828
import type { Application } from './application.js';
2929
import Context from '../app/extend/context.js';
30-
import type { EggAppConfig } from './type.js';
30+
import type { EggAppConfig } from './types.js';
3131
import { create as createMessenger, IMessenger } from './core/messenger/index.js';
3232
import { ContextHttpClient } from './core/context_httpclient.js';
3333
import {

src/lib/type.ts renamed to src/lib/types.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,35 @@ export interface EggAppConfig {
333333
}
334334

335335
export type RequestObjectBody = Record<string, any>;
336+
337+
/**
338+
* plugin config item interface
339+
*/
340+
export interface IEggPluginItem {
341+
env?: EggEnvType[];
342+
path?: string;
343+
package?: string;
344+
enable?: boolean;
345+
}
346+
347+
export type EggPluginItem = IEggPluginItem | boolean;
348+
349+
/**
350+
* build-in plugin list
351+
*/
352+
export interface EggPlugin {
353+
[key: string]: EggPluginItem | undefined;
354+
onerror?: EggPluginItem;
355+
session?: EggPluginItem;
356+
i18n?: EggPluginItem;
357+
watcher?: EggPluginItem;
358+
multipart?: EggPluginItem;
359+
security?: EggPluginItem;
360+
development?: EggPluginItem;
361+
logrotator?: EggPluginItem;
362+
schedule?: EggPluginItem;
363+
static?: EggPluginItem;
364+
jsonp?: EggPluginItem;
365+
view?: EggPluginItem;
366+
}
367+

test/index.test-d.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { expectType } from 'tsd';
22
import {
33
Context, Application, IBoot, ILifecycleBoot,
44
LoggerLevel,
5+
EggPlugin,
56
} from '../src/index.js';
67
import { HttpClient } from '../src/urllib.js';
78

@@ -67,3 +68,33 @@ expectType<ILifecycleBoot>(appBoot);
6768
expectType<string[]>(appBoot.stages);
6869

6970
expectType<LoggerLevel>('DEBUG');
71+
72+
const plugin: EggPlugin = {
73+
tegg: {
74+
enable: true,
75+
package: '@eggjs/tegg-plugin',
76+
},
77+
teggConfig: {
78+
enable: true,
79+
package: '@eggjs/tegg-config',
80+
},
81+
teggController: {
82+
enable: true,
83+
package: '@eggjs/tegg-controller-plugin',
84+
},
85+
teggSchedule: {
86+
enable: true,
87+
package: '@eggjs/tegg-schedule-plugin',
88+
},
89+
eventbusModule: {
90+
enable: true,
91+
package: '@eggjs/tegg-eventbus-plugin',
92+
},
93+
aopModule: {
94+
enable: true,
95+
package: '@eggjs/tegg-aop-plugin',
96+
},
97+
onerror: true,
98+
logrotator: true,
99+
};
100+
expectType<EggPlugin>(plugin);

0 commit comments

Comments
 (0)