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"; /** * 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 // 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 // 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)}, ]