Skip to content

Commit

Permalink
增加beforeApplicationInit回调
Browse files Browse the repository at this point in the history
  • Loading branch information
mybios committed Sep 3, 2024
1 parent d0acb73 commit 807fe36
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/pinus/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type AConfigureFunc2 = (env: string) => Promise<void> ;
export type AConfigureFunc3 = (env: string, type: string) => Promise<void>;

export interface ApplicationOptions {
beforeApplicationInit ?: (app: Application, cb: ()=>void)=>void;
base?: string;
}

Expand Down Expand Up @@ -179,10 +180,19 @@ export class Application {
this.set(Constants.RESERVED.BASE, base);
this.base = base;

appUtil.defaultConfiguration(this);

let init = ()=>{
appUtil.defaultConfiguration(this);

this.state = STATE_INITED;
logger.info('application inited: %j', this.getServerId());
this.state = STATE_INITED;
logger.info('application inited: %j', this.getServerId());
}
let beforeApplicationInit = opts.beforeApplicationInit;
if(!!beforeApplicationInit){
beforeApplicationInit(this, init);
}else{
init();
}
}

/**
Expand Down

0 comments on commit 807fe36

Please sign in to comment.