Skip to content

Commit 1036f99

Browse files
committed
fix: make AdminForth instance single, also export global.adminforth so any code can use it at global level, adminforth instance is single in node environment
1 parent af3d320 commit 1036f99

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

adminforth/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ class AdminForth implements IAdminForth {
125125
}
126126

127127
constructor(config: AdminForthInputConfig) {
128+
if (global.adminforth) {
129+
throw new Error('AdminForth instance already created in this process. '+
130+
'If you want to use multiple instances, consider using different process for each instance');
131+
}
128132
this.codeInjector = new CodeInjector(this);
129133
this.configValidator = new ConfigValidator(this, config);
130134
this.restApi = new AdminForthRestAPI(this);

0 commit comments

Comments
 (0)