2019-11-21 17:06:50 +00:00
|
|
|
import { WelcomeController } from "./WelcomeController";
|
2019-11-22 07:50:15 +00:00
|
|
|
import { RequestHandler } from "../entities/RequestHandler";
|
|
|
|
import { AccountController } from "./AccountController";
|
2019-11-23 14:11:33 +00:00
|
|
|
import { UserController } from "./UserController";
|
2019-11-23 17:41:13 +00:00
|
|
|
import { ConversationsController } from "./ConversationsController";
|
2019-11-30 08:28:50 +00:00
|
|
|
import { SearchController } from "./SearchController";
|
2019-11-21 17:06:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Controllers routes
|
|
|
|
*
|
|
|
|
* @author Pierre Hubert
|
|
|
|
*/
|
|
|
|
|
|
|
|
export enum RouteType {
|
|
|
|
POST, // Default
|
|
|
|
GET
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Route {
|
|
|
|
type ?: RouteType,
|
|
|
|
path: string,
|
2019-11-23 12:24:24 +00:00
|
|
|
cb: (req : RequestHandler) => Promise<void> | void,
|
2019-11-23 12:47:06 +00:00
|
|
|
needLogin ?: boolean, // Default = true
|
2019-11-21 17:06:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const Routes : Route[] = [
|
|
|
|
|
|
|
|
// Welcome controller
|
2019-11-23 12:47:06 +00:00
|
|
|
{type: RouteType.GET, path: "/", cb: WelcomeController.HomeMessage, needLogin: false},
|
2019-11-21 17:06:50 +00:00
|
|
|
|
2019-11-22 07:50:15 +00:00
|
|
|
// Account controller
|
2019-11-23 14:23:48 +00:00
|
|
|
{path: "/account/login", cb: (h) => AccountController.LoginUser(h), needLogin: false},
|
|
|
|
{path: "/user/connectUSER", cb: (h) => AccountController.LoginUser(h), needLogin: false}, // Legacy
|
2019-11-23 13:03:14 +00:00
|
|
|
|
2019-11-23 14:23:48 +00:00
|
|
|
{path: "/account/logout", cb: (h) => AccountController.LogoutUser(h)},
|
|
|
|
{path: "/user/disconnectUSER", cb: (h) => AccountController.LogoutUser(h)}, // Legacy
|
2019-11-23 12:48:16 +00:00
|
|
|
|
2019-11-23 14:23:48 +00:00
|
|
|
{path: "/account/id", cb: (h) => AccountController.CurrentUserID(h)},
|
|
|
|
{path: "/user/getCurrentUserID", cb: (h) => AccountController.CurrentUserID(h)}, // Legacy
|
2019-11-23 14:11:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
// User controller
|
2019-11-23 14:23:48 +00:00
|
|
|
{path: "/user/getInfo", cb: (h) => UserController.GetSingle(h), needLogin: false},
|
|
|
|
{path: "/user/getInfos", cb: (h) => UserController.GetSingle(h), needLogin: false}, // Legacy
|
2019-11-23 14:11:33 +00:00
|
|
|
|
2019-11-23 14:23:48 +00:00
|
|
|
{path: "/user/getInfoMultiple", cb: (h) => UserController.GetMultiple(h), needLogin: false},
|
|
|
|
{path: "/user/getInfosMultiple", cb: (h) => UserController.GetMultiple(h), needLogin: false}, // Legacy
|
2019-11-23 17:41:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Conversations controller
|
2019-11-30 09:11:51 +00:00
|
|
|
{path: "/conversations/create", cb: (h) => ConversationsController.CreateConversation(h)},
|
|
|
|
|
2019-11-23 17:41:13 +00:00
|
|
|
{path: "/conversations/getList", cb: (h) => ConversationsController.GetList(h)},
|
2019-11-23 19:53:13 +00:00
|
|
|
|
|
|
|
{path: "/conversations/getInfoOne", cb: (h) => ConversationsController.GetInfoSingle(h)},
|
|
|
|
{path: "/conversations/getInfosOne", cb: (h) => ConversationsController.GetInfoSingle(h)}, // Legacy
|
2019-11-30 08:28:50 +00:00
|
|
|
|
2019-11-30 11:24:19 +00:00
|
|
|
{path: "/conversations/updateSettings", cb: (h) => ConversationsController.UpdateSettings(h)},
|
2019-11-30 08:28:50 +00:00
|
|
|
|
2019-12-07 11:00:28 +00:00
|
|
|
{path: "/conversations/getPrivate", cb: (h) => ConversationsController.FindPrivate(h)},
|
|
|
|
|
2019-11-30 14:17:47 +00:00
|
|
|
{path: "/conversations/refresh", cb: (h) => ConversationsController.RefreshList(h)},
|
2019-11-30 15:44:27 +00:00
|
|
|
|
|
|
|
{path: "/conversations/refresh_single", cb: (h) => ConversationsController.RefreshSingleConversation(h)},
|
2019-11-30 16:13:36 +00:00
|
|
|
|
|
|
|
{path: "/conversations/sendMessage", cb: (h) => ConversationsController.SendMessage(h)},
|
2019-12-07 16:08:53 +00:00
|
|
|
|
|
|
|
{path: "/conversations/get_older_messages", cb: (h) => ConversationsController.GetOlderMessages(h)},
|
2019-12-07 16:15:33 +00:00
|
|
|
|
2019-12-07 16:35:14 +00:00
|
|
|
{path: "/conversations/get_number_unread", cb: (h) => ConversationsController.CountUnreadForUser(h)},
|
|
|
|
|
|
|
|
{path: "/conversations/get_list_unread", cb: (h) => ConversationsController.GetListUnread(h)},
|
2019-12-07 17:06:41 +00:00
|
|
|
|
|
|
|
{path: "/conversations/delete", cb: (h) => ConversationsController.DeleteConversation(h)},
|
2019-11-30 14:17:47 +00:00
|
|
|
|
|
|
|
|
2019-11-30 08:28:50 +00:00
|
|
|
// Search controller
|
|
|
|
{path: "/search/user", cb: (h) => SearchController.SearchUser(h)},
|
|
|
|
{path: "/user/search", cb: (h) => SearchController.SearchUser(h)}, // Legacy
|
2019-11-21 17:06:50 +00:00
|
|
|
]
|