mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-30 01:06:28 +00:00
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
import { WelcomeController } from "./WelcomeController";
|
|
import { RequestHandler } from "../entities/RequestHandler";
|
|
import { AccountController } from "./AccountController";
|
|
import { UserController } from "./UserController";
|
|
import { ConversationsController } from "./ConversationsController";
|
|
|
|
/**
|
|
* 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/getList", cb: (h) => ConversationsController.GetList(h)},
|
|
|
|
{path: "/conversations/getInfoOne", cb: (h) => ConversationsController.GetInfoSingle(h)},
|
|
{path: "/conversations/getInfosOne", cb: (h) => ConversationsController.GetInfoSingle(h)}, // Legacy
|
|
] |