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"; /** * 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)}, // Search controller {path: "/search/user", cb: (h) => SearchController.SearchUser(h)}, {path: "/user/search", cb: (h) => SearchController.SearchUser(h)}, // Legacy ]