-
-
Notifications
You must be signed in to change notification settings - Fork 116
/
controller-instance.ts
123 lines (100 loc) · 3.73 KB
/
controller-instance.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import {
EnvironmentController,
EventController,
IntegrationController,
ProjectController,
SecretController,
VariableController,
WorkspaceController,
WorkspaceRoleController,
WorkspaceMembershipController
} from '@keyshade/api-client'
export default class ControllerInstance {
private static instance: ControllerInstance | null
private _environmentController: EnvironmentController | null = null
get environmentController(): EnvironmentController {
if (!this._environmentController) {
throw new Error('ControllerInstance not initialized')
}
return this._environmentController
}
private _eventController: EventController | null = null
get eventController(): EventController {
if (!this._eventController) {
throw new Error('ControllerInstance not initialized')
}
return this._eventController
}
private _integrationController: IntegrationController | null = null
get integrationController(): IntegrationController {
if (!this._integrationController) {
throw new Error('ControllerInstance not initialized')
}
return this._integrationController
}
private _projectController: ProjectController | null = null
get projectController(): ProjectController {
if (!this._projectController) {
throw new Error('ControllerInstance not initialized')
}
return this._projectController
}
private _secretController: SecretController | null = null
get secretController(): SecretController {
if (!this._secretController) {
throw new Error('ControllerInstance not initialized')
}
return this._secretController
}
private _variableController: VariableController | null = null
get variableController(): VariableController {
if (!this._variableController) {
throw new Error('ControllerInstance not initialized')
}
return this._variableController
}
private _workspaceController: WorkspaceController | null = null
get workspaceController(): WorkspaceController {
if (!this._workspaceController) {
throw new Error('ControllerInstance not initialized')
}
return this._workspaceController
}
private _workspaceRoleController: WorkspaceRoleController | null = null
get workspaceRoleController(): WorkspaceRoleController {
if (!this._workspaceRoleController) {
throw new Error('ControllerInstance not initialized')
}
return this._workspaceRoleController
}
private _workspaceMembershipController: WorkspaceMembershipController | null =
null
get workspaceMembershipController(): WorkspaceMembershipController {
if (!this._workspaceMembershipController) {
throw new Error('ControllerInstance not initialized')
}
return this._workspaceMembershipController
}
static initialize(baseUrl: string) {
if (!ControllerInstance.instance) {
const instance = new ControllerInstance()
instance._environmentController = new EnvironmentController(baseUrl)
instance._eventController = new EventController(baseUrl)
instance._integrationController = new IntegrationController(baseUrl)
instance._projectController = new ProjectController(baseUrl)
instance._secretController = new SecretController(baseUrl)
instance._variableController = new VariableController(baseUrl)
instance._workspaceController = new WorkspaceController(baseUrl)
instance._workspaceRoleController = new WorkspaceRoleController(baseUrl)
instance._workspaceMembershipController =
new WorkspaceMembershipController(baseUrl)
ControllerInstance.instance = instance
}
}
static getInstance(): ControllerInstance {
if (!ControllerInstance.instance) {
throw new Error('ControllerInstance not initialized')
}
return ControllerInstance.instance
}
}