File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 */
44
55import { BaseContextClass } from './lib/core/base_context_class.js' ;
6- import { startEgg } from './lib/start.js' ;
6+ import {
7+ startEgg ,
8+ SingleModeApplication ,
9+ SingleModeAgent ,
10+ } from './lib/start.js' ;
711import Helper from './app/extend/helper.js' ;
812
913// export extends
@@ -45,6 +49,8 @@ export * from '@eggjs/cluster';
4549 */
4650export {
4751 startEgg as start ,
52+ SingleModeApplication ,
53+ SingleModeAgent ,
4854} ;
4955
5056/**
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { readJSON } from 'utility';
33import { importModule } from '@eggjs/utils' ;
44import { Agent } from './agent.js' ;
55import { Application } from './application.js' ;
6+ import { EggPlugin } from './types.js' ;
67
78export interface StartEggOptions {
89 /** specify framework that can be absolute path or npm package */
@@ -13,6 +14,15 @@ export interface StartEggOptions {
1314 ignoreWarning ?: boolean ;
1415 mode ?: 'single' ;
1516 env ?: string ;
17+ plugins ?: EggPlugin ;
18+ }
19+
20+ export interface SingleModeApplication extends Application {
21+ agent : SingleModeAgent ;
22+ }
23+
24+ export interface SingleModeAgent extends Agent {
25+ app : SingleModeApplication ;
1626}
1727
1828/**
@@ -41,11 +51,11 @@ export async function startEgg(options: StartEggOptions = {}) {
4151
4252 const agent = new AgentClass ( {
4353 ...options ,
44- } ) ;
54+ } ) as SingleModeAgent ;
4555 await agent . ready ( ) ;
4656 const application = new ApplicationClass ( {
4757 ...options ,
48- } ) ;
58+ } ) as SingleModeApplication ;
4959 application . agent = agent ;
5060 agent . application = application ;
5161 await application . ready ( ) ;
Original file line number Diff line number Diff line change 44 LoggerLevel ,
55 EggPlugin ,
66 EggAppInfo ,
7+ start , SingleModeApplication , SingleModeAgent ,
78} from '../src/index.js' ;
89import { HttpClient } from '../src/urllib.js' ;
910
@@ -113,3 +114,13 @@ expectType<EggAppInfo>({
113114 scope : 'scope' ,
114115 root : 'root' ,
115116} ) ;
117+
118+ const singleApp = await start ( {
119+ baseDir : 'baseDir' ,
120+ framework : 'egg' ,
121+ plugins : plugin ,
122+ } ) ;
123+
124+ expectType < SingleModeApplication > ( singleApp ) ;
125+ expectType < SingleModeAgent > ( singleApp . agent ) ;
126+ expectType < SingleModeApplication > ( singleApp . agent . app ) ;
You can’t perform that action at this time.
0 commit comments