import { WelcomeController } from "./WelcomeController"; import { RequestHandler } from "../entities/RequestHandler"; import { AccountController } from "./AccountController"; import { UserController } from "./UserController"; import { ConversationsController } from "./ConversationsController"; import { SearchController } from "./SearchController"; import { GroupsController } from "./GroupsController"; import { NotificationsController } from "./NotificationsController"; import { VirtualDirectoryController } from "./VirtualDirectoryController"; import { WebAppControllers } from "./WebAppController"; import { CallsController } from "./CallsController"; /** * Controllers routes * * @author Pierre Hubert */ export enum RouteType { POST, // Default GET } export interface Route { type ?: RouteType, path: string, cb: (req : RequestHandler) => Promise | void, needLogin ?: boolean, // Default = true } export const Routes : Route[] = [ // Welcome controller {type: RouteType.GET, path: "/", cb: WelcomeController.HomeMessage, needLogin: false}, // Account controller {path: "/account/login", cb: (h) => AccountController.LoginUser(h), needLogin: false}, {path: "/user/connectUSER", cb: (h) => AccountController.LoginUser(h), needLogin: false}, // Legacy {path: "/account/logout", cb: (h) => AccountController.LogoutUser(h)}, {path: "/user/disconnectUSER", cb: (h) => AccountController.LogoutUser(h)}, // Legacy {path: "/account/id", cb: (h) => AccountController.CurrentUserID(h)}, {path: "/user/getCurrentUserID", cb: (h) => AccountController.CurrentUserID(h)}, // Legacy {path: "/account/exists_email", cb: (h) => AccountController.ExistsMail(h), needLogin: false}, {path: "/account/has_security_questions", cb: (h) => AccountController.HasSecurityQuestions(h), needLogin: false}, {path: "/account/get_security_questions", cb: (h) => AccountController.GetSecurityQuestions(h), needLogin: false}, {path: "/account/check_security_answers", cb: (h) => AccountController.CheckSecurityAnswers(h), needLogin: false}, {path: "/account/check_password_reset_token", cb: (h) => AccountController.CheckPasswordResetToken(h), needLogin: false}, // User controller {path: "/user/getInfo", cb: (h) => UserController.GetSingle(h), needLogin: false}, {path: "/user/getInfos", cb: (h) => UserController.GetSingle(h), needLogin: false}, // Legacy {path: "/user/getInfoMultiple", cb: (h) => UserController.GetMultiple(h), needLogin: false}, {path: "/user/getInfosMultiple", cb: (h) => UserController.GetMultiple(h), needLogin: false}, // Legacy {path: "/user/getAdvancedUserInfo", cb: (h) => UserController.GetAdvancedInfo(h), needLogin: false}, {path: "/user/getAdvancedUserInfos", cb: (h) => UserController.GetAdvancedInfo(h), needLogin: false}, // Legacy // Conversations controller {path: "/conversations/create", cb: (h) => ConversationsController.CreateConversation(h)}, {path: "/conversations/getList", cb: (h) => ConversationsController.GetList(h)}, {path: "/conversations/getInfoOne", cb: (h) => ConversationsController.GetInfoSingle(h)}, {path: "/conversations/getInfosOne", cb: (h) => ConversationsController.GetInfoSingle(h)}, // Legacy {path: "/conversations/updateSettings", cb: (h) => ConversationsController.UpdateSettings(h)}, {path: "/conversations/getPrivate", cb: (h) => ConversationsController.FindPrivate(h)}, {path: "/conversations/refresh", cb: (h) => ConversationsController.RefreshList(h)}, {path: "/conversations/refresh_single", cb: (h) => ConversationsController.RefreshSingleConversation(h)}, {path: "/conversations/sendMessage", cb: (h) => ConversationsController.SendMessage(h)}, {path: "/conversations/get_older_messages", cb: (h) => ConversationsController.GetOlderMessages(h)}, {path: "/conversations/get_number_unread", cb: (h) => ConversationsController.CountUnreadForUser(h)}, {path: "/conversations/get_list_unread", cb: (h) => ConversationsController.GetListUnread(h)}, {path: "/conversations/delete", cb: (h) => ConversationsController.DeleteConversation(h)}, {path: "/conversations/updateMessage", cb: (h) => ConversationsController.UpdateMessage(h)}, {path: "/conversations/deleteMessage", cb: (h) => ConversationsController.DeleteMessage(h)}, // Search controller {path: "/search/user", cb: (h) => SearchController.SearchUser(h)}, {path: "/user/search", cb: (h) => SearchController.SearchUser(h)}, // Legacy // Groups controller {path: "/groups/create", cb: (h) => GroupsController.Create(h)}, {path: "/groups/get_my_list", cb: (h) => GroupsController.GetListUser(h)}, {path: "/groups/get_info", cb: (h) => GroupsController.GetInfoSingle(h)}, {path: "/groups/get_multiple_info", cb: (h) => GroupsController.GetInfoMultiple(h)}, {path: "/groups/get_advanced_info", cb: (h) => GroupsController.GetAdvancedInfo(h), needLogin: false}, {path: "/groups/get_settings", cb: (h) => GroupsController.GetSettings(h)}, {path: "/groups/set_settings", cb: (h) => GroupsController.SetSettings(h)}, {path: "/groups/checkVirtualDirectory", cb: (h) => GroupsController.CheckVirtualDirectory(h)}, {path: "/groups/upload_logo", cb: (h) => GroupsController.UploadLogo(h)}, {path: "/groups/delete_logo", cb: (h) => GroupsController.DeleteLogo(h)}, {path: "/groups/get_members", cb: (h) => GroupsController.GetMembers(h)}, {path: "/groups/invite", cb: (h) => GroupsController.InviteUser(h)}, {path: "/groups/respond_invitation", cb: (h) => GroupsController.RespondInvitation(h)}, {path: "/groups/send_request", cb: (h) => GroupsController.SendRequest(h)}, {path: "/groups/cancel_request", cb: (h) => GroupsController.CancelRequest(h)}, {path: "/groups/delete_member", cb: (h) => GroupsController.DeleteMember(h)}, {path: "/groups/update_membership_level", cb: (h) => GroupsController.UpdateMembership(h)}, {path: "/groups/respond_request", cb: (h) => GroupsController.RespondRequest(h)}, {path: "/groups/get_membership", cb: (h) => GroupsController.GetMembership(h)}, {path: "/groups/cancel_invitation", cb: (h) => GroupsController.CancelInvitation(h)}, {path: "/groups/remove_membership", cb: (h) => GroupsController.RemoveMembership(h)}, {path: "/groups/set_following", cb: (h) => GroupsController.SetFollowing(h)}, {path: "/groups/delete", cb: (h) => GroupsController.DeleteGroup(h)}, // Notifications controller {path: "/notifications/count_unread", cb: (h) => NotificationsController.CountUnread(h)}, {path: "/notifications/count_all_news", cb: (h) => NotificationsController.CountAllNews(h)}, {path: "/notifications/get_list_unread", cb: (h) => NotificationsController.GetListUnread(h)}, // Virtual directory controller {path: "/user/findbyfolder", cb: (h) => VirtualDirectoryController.FindUser(h)}, {path: "/virtualDirectory/find", cb: (h) => VirtualDirectoryController.Find(h)}, // Web app controller {path: "/webApp/getMemberships", cb: (h) => WebAppControllers.GetMemberships(h)}, // Calls controller {path: "/calls/config", cb: (h) => CallsController.GetConfig(h)}, ]