1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-26 15:29:22 +00:00
comunicapiv2/src/controllers/Routes.ts

68 lines
2.5 KiB
TypeScript

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> | 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/refresh", cb: (h) => ConversationsController.RefreshList(h)},
{path: "/conversations/refresh_single", cb: (h) => ConversationsController.RefreshSingleConversation(h)},
// Search controller
{path: "/search/user", cb: (h) => SearchController.SearchUser(h)},
{path: "/user/search", cb: (h) => SearchController.SearchUser(h)}, // Legacy
]