1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-19 13:19:41 +02:00
mealie/frontend/api/index.ts

54 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-08-01 19:24:47 -08:00
import { RecipeAPI } from "./class-interfaces/recipes";
import { UserApi } from "./class-interfaces/users";
import { GroupAPI } from "./class-interfaces/groups";
import { DebugAPI } from "./class-interfaces/debug";
import { EventsAPI } from "./class-interfaces/events";
import { BackupAPI } from "./class-interfaces/backups";
import { UploadFile } from "./class-interfaces/upload";
import { CategoriesAPI } from "./class-interfaces/categories";
import { TagsAPI } from "./class-interfaces/tags";
2021-08-01 19:24:47 -08:00
import { ApiRequestInstance } from "~/types/api";
2021-08-01 19:24:47 -08:00
class Api {
private static instance: Api;
public recipes: RecipeAPI;
public users: UserApi;
public groups: GroupAPI;
public debug: DebugAPI;
public events: EventsAPI;
public backups: BackupAPI;
public categories: CategoriesAPI;
public tags: TagsAPI;
// Utils
public upload: UploadFile;
2021-08-01 19:24:47 -08:00
constructor(requests: ApiRequestInstance) {
if (Api.instance instanceof Api) {
return Api.instance;
}
// Recipes
2021-08-01 19:24:47 -08:00
this.recipes = new RecipeAPI(requests);
this.categories = new CategoriesAPI(requests);
this.tags = new TagsAPI(requests);
// Users
this.users = new UserApi(requests);
this.groups = new GroupAPI(requests);
// Admin
this.debug = new DebugAPI(requests);
this.events = new EventsAPI(requests);
this.backups = new BackupAPI(requests);
// Utils
this.upload = new UploadFile(requests);
2021-08-01 19:24:47 -08:00
Object.freeze(this);
Api.instance = this;
}
}
export { Api };