Skip to content

Commit e0405b3

Browse files
committed
refactor: divide managers into services and modules
1 parent aab8fae commit e0405b3

File tree

21 files changed

+131
-115
lines changed

21 files changed

+131
-115
lines changed

src/index.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { assertString } from "./assertions/literal";
2-
import {
3-
APIManager,
4-
ApplicationManager,
5-
CacheManager,
6-
UserManager,
7-
} from "./managers";
2+
import { ApplicationModule, UserModule } from "./modules";
3+
import { APIService, GlobalCacheService } from "./services";
84
import { type ClientEvents, TypedEventEmitter } from "./types";
95

106
export class SquareCloudAPI extends TypedEventEmitter<ClientEvents> {
@@ -13,14 +9,15 @@ export class SquareCloudAPI extends TypedEventEmitter<ClientEvents> {
139
baseUrl: "https://api.squarecloud.app/",
1410
};
1511

16-
public readonly api: APIManager;
12+
/** The API service */
13+
public readonly api: APIService;
1714

18-
/** The applications manager */
19-
public applications = new ApplicationManager(this);
20-
/** The users manager */
21-
public users = new UserManager(this);
22-
/** The global cache manager */
23-
public cache = new CacheManager();
15+
/** The applications module */
16+
public applications = new ApplicationModule(this);
17+
/** The users module */
18+
public users = new UserModule(this);
19+
/** The global cache service */
20+
public cache = new GlobalCacheService();
2421

2522
/**
2623
* Creates an API instance
@@ -31,10 +28,10 @@ export class SquareCloudAPI extends TypedEventEmitter<ClientEvents> {
3128
super();
3229

3330
assertString(apiKey, "API_KEY");
34-
this.api = new APIManager(apiKey);
31+
this.api = new APIService(apiKey);
3532
}
3633
}
3734

38-
export * from "./managers";
35+
export * from "./services";
3936
export * from "./structures";
4037
export * from "./types";

src/managers/application/cache.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/managers/cache.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/managers/index.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { assertPathLike, assertString } from "@/assertions/literal";
2+
import { Routes } from "@/lib/routes";
23
import {
34
Application,
45
type BaseApplication,
56
type Collection,
67
SimpleApplicationStatus,
7-
type SquareCloudAPI,
88
SquareCloudAPIError,
99
User,
10-
} from "@/index";
11-
import { Routes } from "@/lib/routes";
10+
} from "@/structures";
1211
import type { RESTPostAPIApplicationUploadResult } from "@squarecloud/api-types/v2";
1312
import FormData from "form-data";
1413
import { readFile } from "fs/promises";
14+
import type { SquareCloudAPI } from "..";
1515

16-
export class ApplicationManager {
16+
export class ApplicationModule {
1717
constructor(public readonly client: SquareCloudAPI) {}
1818

1919
/**
@@ -100,7 +100,7 @@ export class ApplicationManager {
100100
}
101101

102102
export * from "./backups";
103-
export * from "./cache";
103+
export * from "../services/cache/application";
104104
export * from "./deploys";
105105
export * from "./files";
106106
export * from "./network";
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { type BaseApplication, SquareCloudAPIError } from "@/index";
21
import { Routes } from "@/lib/routes";
2+
import { type BaseApplication, SquareCloudAPIError } from "@/structures";
33
import type {
44
APIApplicationBackup,
55
RESTPostAPIApplicationBackupResult,
66
} from "@squarecloud/api-types/v2";
77

8-
export class ApplicationBackupsManager {
8+
export class BackupsModule {
99
constructor(public readonly application: BaseApplication) {}
1010

1111
async list(): Promise<APIApplicationBackup[]> {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { assertString } from "@/assertions/literal";
2-
import type { BaseApplication } from "@/index";
32
import { Routes } from "@/lib/routes";
3+
import type { BaseApplication } from "@/structures";
44

5-
export class ApplicationDeploysManager {
5+
export class DeploysModule {
66
constructor(public readonly application: BaseApplication) {}
77

88
/**
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { join } from "path";
22
import { assertPathLike, assertString } from "@/assertions/literal";
3-
import type { BaseApplication } from "@/index";
43
import { Routes } from "@/lib/routes";
4+
import type { BaseApplication } from "@/structures";
55
import { readFile } from "fs/promises";
66

7-
export class ApplicationFilesManager {
7+
export class FilesModule {
88
constructor(public readonly application: BaseApplication) {}
99

1010
/**

src/modules/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export * from "./application";
2+
export * from "./backups";
3+
export * from "./deploys";
4+
export * from "./files";
5+
export * from "./network";
6+
export * from "./user";
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { assertString } from "@/assertions/literal";
2-
import type { WebsiteApplication } from "@/index";
32
import { Routes } from "@/lib/routes";
3+
import type { WebsiteApplication } from "@/structures";
44

5-
export class ApplicationNetworkManager {
5+
export class NetworkModule {
66
constructor(public readonly application: WebsiteApplication) {}
77

88
/**

0 commit comments

Comments
 (0)