2020-09-06 16:15:25 +00:00
|
|
|
import { IRouteProps } from 'inferno-router/dist/Route';
|
|
|
|
import { Main } from './components/main';
|
|
|
|
import { Login } from './components/login';
|
|
|
|
import { CreatePost } from './components/create-post';
|
|
|
|
import { CreateCommunity } from './components/create-community';
|
|
|
|
import { CreatePrivateMessage } from './components/create-private-message';
|
|
|
|
import { PasswordChange } from './components/password_change';
|
|
|
|
import { Post } from './components/post';
|
|
|
|
import { Community } from './components/community';
|
|
|
|
import { Communities } from './components/communities';
|
|
|
|
import { User } from './components/user';
|
|
|
|
import { Modlog } from './components/modlog';
|
|
|
|
import { Setup } from './components/setup';
|
|
|
|
import { AdminSettings } from './components/admin-settings';
|
|
|
|
import { Inbox } from './components/inbox';
|
|
|
|
import { Search } from './components/search';
|
|
|
|
import { Instances } from './components/instances';
|
2020-11-12 21:56:46 +00:00
|
|
|
import { InitialFetchRequest } from './interfaces';
|
2020-09-06 16:15:25 +00:00
|
|
|
|
2020-09-07 03:41:46 +00:00
|
|
|
interface IRoutePropsWithFetch extends IRouteProps {
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData?(req: InitialFetchRequest): Promise<any>[];
|
2020-09-07 03:41:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const routes: IRoutePropsWithFetch[] = [
|
2020-09-08 04:09:11 +00:00
|
|
|
{
|
|
|
|
path: `/`,
|
2020-09-08 18:44:55 +00:00
|
|
|
exact: true,
|
2020-09-08 04:09:11 +00:00
|
|
|
component: Main,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Main.fetchInitialData(req),
|
2020-09-08 04:09:11 +00:00
|
|
|
},
|
2020-09-06 16:15:25 +00:00
|
|
|
{
|
|
|
|
path: `/home/data_type/:data_type/listing_type/:listing_type/sort/:sort/page/:page`,
|
|
|
|
component: Main,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Main.fetchInitialData(req),
|
2020-09-06 16:15:25 +00:00
|
|
|
},
|
2020-09-09 03:13:26 +00:00
|
|
|
{
|
|
|
|
path: `/login`,
|
|
|
|
component: Login,
|
|
|
|
},
|
2020-09-07 22:24:48 +00:00
|
|
|
{
|
|
|
|
path: `/create_post`,
|
|
|
|
component: CreatePost,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => CreatePost.fetchInitialData(req),
|
2020-09-07 22:24:48 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/create_community`,
|
|
|
|
component: CreateCommunity,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => CreateCommunity.fetchInitialData(req),
|
2020-09-07 22:24:48 +00:00
|
|
|
},
|
2020-09-06 16:15:25 +00:00
|
|
|
{
|
2020-09-08 18:44:55 +00:00
|
|
|
path: `/create_private_message/recipient/:recipient_id`,
|
2020-09-06 16:15:25 +00:00
|
|
|
component: CreatePrivateMessage,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => CreatePrivateMessage.fetchInitialData(req),
|
2020-09-06 16:15:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/communities/page/:page`,
|
|
|
|
component: Communities,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Communities.fetchInitialData(req),
|
2020-09-07 03:41:46 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/communities`,
|
|
|
|
component: Communities,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Communities.fetchInitialData(req),
|
2020-09-06 16:15:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/post/:id/comment/:comment_id`,
|
|
|
|
component: Post,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Post.fetchInitialData(req),
|
2020-09-09 00:48:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/post/:id`,
|
|
|
|
component: Post,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Post.fetchInitialData(req),
|
2020-09-06 16:15:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/c/:name/data_type/:data_type/sort/:sort/page/:page`,
|
|
|
|
component: Community,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Community.fetchInitialData(req),
|
2020-09-08 15:17:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/community/:id`,
|
|
|
|
component: Community,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Community.fetchInitialData(req),
|
2020-09-08 15:17:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/c/:name`,
|
|
|
|
component: Community,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Community.fetchInitialData(req),
|
2020-09-06 16:15:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/u/:username/view/:view/sort/:sort/page/:page`,
|
|
|
|
component: User,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => User.fetchInitialData(req),
|
2020-09-09 00:48:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/user/:id`,
|
|
|
|
component: User,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => User.fetchInitialData(req),
|
2020-09-09 00:48:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/u/:username`,
|
|
|
|
component: User,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => User.fetchInitialData(req),
|
2020-09-09 00:48:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/inbox`,
|
|
|
|
component: Inbox,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Inbox.fetchInitialData(req),
|
2020-09-06 16:15:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/modlog/community/:community_id`,
|
|
|
|
component: Modlog,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Modlog.fetchInitialData(req),
|
2020-09-09 02:40:36 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/modlog`,
|
|
|
|
component: Modlog,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Modlog.fetchInitialData(req),
|
2020-09-06 16:15:25 +00:00
|
|
|
},
|
|
|
|
{ path: `/setup`, component: Setup },
|
2020-09-09 02:40:36 +00:00
|
|
|
{
|
|
|
|
path: `/admin`,
|
|
|
|
component: AdminSettings,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => AdminSettings.fetchInitialData(req),
|
2020-09-09 02:40:36 +00:00
|
|
|
},
|
2020-09-06 16:15:25 +00:00
|
|
|
{
|
|
|
|
path: `/search/q/:q/type/:type/sort/:sort/page/:page`,
|
|
|
|
component: Search,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Search.fetchInitialData(req),
|
2020-09-09 02:40:36 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/search`,
|
|
|
|
component: Search,
|
2020-11-12 21:56:46 +00:00
|
|
|
fetchInitialData: req => Search.fetchInitialData(req),
|
2020-09-06 16:15:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: `/password_change/:token`,
|
|
|
|
component: PasswordChange,
|
|
|
|
},
|
|
|
|
{ path: `/instances`, component: Instances },
|
|
|
|
];
|