Skip to content

Commit cfaed19

Browse files
committed
Made apiManager totally private
1 parent 4a59340 commit cfaed19

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/structures/Application.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export class Application {
4141
/** Whether the application is a website or not */
4242
isWebsite: boolean;
4343

44-
constructor(private apiManager: APIManager, data: RawApplicationData) {
44+
#apiManager: APIManager;
45+
46+
constructor(apiManager: APIManager, data: RawApplicationData) {
4547
this.id = data.id;
4648
this.tag = data.tag;
4749
this.ram = data.ram;
@@ -50,6 +52,8 @@ export class Application {
5052
this.avatar = data.avatar;
5153
this.cluster = data.cluster;
5254
this.isWebsite = data.isWebsite;
55+
56+
this.#apiManager = apiManager;
5357
}
5458

5559
/** Gets the application's current information */
@@ -64,7 +68,7 @@ export class Application {
6468
status,
6569
uptime,
6670
time,
67-
} = (await this.apiManager.application('status', this.id)).response;
71+
} = (await this.#apiManager.application('status', this.id)).response;
6872

6973
return {
7074
status,
@@ -89,33 +93,33 @@ export class Application {
8993
validateBoolean(full, '[LOGS_FULL]');
9094

9195
return (
92-
await this.apiManager.application(`${full ? 'full-' : ''}logs`, this.id)
96+
await this.#apiManager.application(`${full ? 'full-' : ''}logs`, this.id)
9397
).response.logs;
9498
}
9599

96100
/** Generates the backup download URL */
97101
async backup(): Promise<string> {
98-
return (await this.apiManager.application('backup', this.id)).response
102+
return (await this.#apiManager.application('backup', this.id)).response
99103
.downloadURL;
100104
}
101105

102106
/** Starts up the application */
103107
async start(): Promise<boolean> {
104-
const { code } = await this.apiManager.application('start', this.id, true);
108+
const { code } = await this.#apiManager.application('start', this.id, true);
105109

106110
return code === 'ACTION_SENT';
107111
}
108112

109113
/** Stops the application */
110114
async stop(): Promise<boolean> {
111-
const { code } = await this.apiManager.application('stop', this.id, true);
115+
const { code } = await this.#apiManager.application('stop', this.id, true);
112116

113117
return code === 'ACTION_SENT';
114118
}
115119

116120
/** Restarts the application */
117121
async restart(): Promise<boolean> {
118-
const { code } = await this.apiManager.application(
122+
const { code } = await this.#apiManager.application(
119123
'restart',
120124
this.id,
121125
true
@@ -130,7 +134,7 @@ export class Application {
130134
* - This action is irreversible.
131135
*/
132136
async delete(): Promise<boolean> {
133-
const { code } = await this.apiManager.application('delete', this.id, true);
137+
const { code } = await this.#apiManager.application('delete', this.id, true);
134138

135139
return code === 'APP_DELETED';
136140
}
@@ -174,7 +178,7 @@ export class Application {
174178
);
175179
}
176180

177-
const { code } = await this.apiManager.application('commit', this.id, {
181+
const { code } = await this.#apiManager.application('commit', this.id, {
178182
method: 'POST',
179183
data: formData,
180184
headers: { ...formData.getHeaders() },

src/structures/User.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export class User {
2020
/** Whether you have access to private information or not */
2121
hasAccess: () => this is FullUser;
2222

23-
constructor(private apiManager: APIManager, data: RawUserData) {
23+
#apiManager: APIManager;
24+
25+
constructor(apiManager: APIManager, data: RawUserData) {
2426
this.id = data.user.id;
2527
this.tag = data.user.tag;
2628
this.plan = {
@@ -31,15 +33,17 @@ export class User {
3133
},
3234
};
3335
this.hasAccess = () => data.user.email !== 'Access denied';
36+
37+
this.#apiManager = apiManager;
3438
}
3539

3640
/** Fetches the user data again and returns a new User */
3741
fetch(): Promise<User> {
38-
return this.apiManager
42+
return this.#apiManager
3943
.user(this.id)
4044
.then(
4145
(data) =>
42-
new (this.hasAccess() ? FullUser : User)(this.apiManager, data)
46+
new (this.hasAccess() ? FullUser : User)(this.#apiManager, data)
4347
);
4448
}
4549
}

0 commit comments

Comments
 (0)