refactor(controllers): rewrite old controllers to new syntax
+ 42
- 19
app/controllers/HomeController.ts -> app/controllers/home/getHomeView.ts
@@ -1,9 +1,11 @@
 // 1st-party
 import { ReqHandler } from "@ethicdevs/react-monolith";
 // app views
-import HomeView, { HomeViewProps } from "../views/HomeView";
+import HomeView, { HomeViewProps } from "../../views/HomeView";
 
-export const getHomeView: ReqHandler = async (request, reply) => {
+const getHomeView: ReqHandler = async (request, reply) => {
   const reqHandler = reply.makeRequestHandler(request, reply);
   return reqHandler<HomeViewProps>(HomeView.name, {});
 };
+
+export default getHomeView;

new file
app/controllers/home/index.ts
@@ -0,0 +1,5 @@
+import { default as getHomeView } from "./getHomeView";
+
+export const HomeController = {
+  getHomeView,
+};

new file
app/controllers/index.ts
@@ -0,0 +1,7 @@
+export { AuthController } from "./auth";
+export { HomeController } from "./home";
+export { OrganizationController } from "./organization";
+export { RepositoryController } from "./repository";
+export { SyntaxHighlightController } from "./syntaxHighlight";
+export { ThemeController } from "./theme";
+export { UserController } from "./user";

app/controllers/syntax_highlight/highlightCodeAction.ts -> app/controllers/syntaxHighlight/highlightCodeAction.ts
app/controllers/syntax_highlight/index.ts -> app/controllers/syntaxHighlight/index.ts
app/controllers/syntax_highlight/theme.dark.css -> app/controllers/syntaxHighlight/theme.dark.css
app/controllers/syntax_highlight/theme.light.css -> app/controllers/syntaxHighlight/theme.light.css
new file
app/controllers/theme/index.ts
@@ -0,0 +1,5 @@
+import { default as setThemeSchemeAction } from "./setThemeSchemeAction";
+
+export const ThemeController = {
+  setThemeSchemeAction,
+};

app/controllers/ThemeController.ts -> app/controllers/theme/setThemeSchemeAction.ts
@@ -1,13 +1,15 @@
 // 1st-party
 import { ReqHandler } from "@ethicdevs/react-monolith";
 // app
-import { AppRoute, AppRoutesParams } from "../routes";
+import { AppRoute, AppRoutesParams } from "../../routes";
 
-export const getTheme: ReqHandler = async (request, reply) => {
+const setThemeSchemeAction: ReqHandler = async (request, reply) => {
   const { referer } = request.headers;
   const { themeScheme: desiredScheme } =
-    request.params as AppRoutesParams[AppRoute.SET_THEME]["params"];
+    request.params as AppRoutesParams[AppRoute.THEME_SET_SCHEME_ACTION]["params"];
 
   reply.setCookie("theme_scheme", desiredScheme === "light" ? "light" : "dark");
   return reply.redirect(302, referer || "/");
 };
+
+export default setThemeSchemeAction;

@@ -7,20 +7,22 @@ import React from "react";
 // generated via script[generate:prisma]
 import { ResourceVisibility } from "@prisma/client";
 // app
+import type { AppThemeScheme } from "./types";
 import { authenticatedOrLogin, guestOrRedirect } from "./utils/server";
 // app controllers
-import { AuthController } from "./controllers/auth";
-import { OrganizationController } from "./controllers/organization";
-import { RepositoryController } from "./controllers/repository";
-import { UserController } from "./controllers/user";
-import * as HomeController from "./controllers/HomeController";
-import * as ThemeController from "./controllers/ThemeController";
-import { AppThemeScheme } from "./types";
-import { SyntaxHighlightController } from "./controllers/syntax_highlight";
+import {
+  AuthController,
+  HomeController,
+  OrganizationController,
+  RepositoryController,
+  SyntaxHighlightController,
+  ThemeController,
+  UserController,
+} from "./controllers";
 
 export enum AppRoute {
   HOME = "home",
-  SET_THEME = "set_theme.action",
+  THEME_SET_SCHEME_ACTION = "theme.set_scheme.action",
   AUTH_REGISTER = "auth.register",
   AUTH_REGISTER_ACTION = "auth.register.action",
   AUTH_LOGIN = "auth.login",

...
@@ -45,7 +47,7 @@ export enum AppRoute {
 
 export interface AppRoutesParams extends IRouteParams {
   [AppRoute.HOME]: undefined;
-  [AppRoute.SET_THEME]: {
+  [AppRoute.THEME_SET_SCHEME_ACTION]: {
     params: {
       themeScheme: string;
     };

...
@@ -168,7 +170,7 @@ export interface AppRoutesParams extends IRouteParams {
 
 export const AppRoutesSchemas: Record<AppRoute, undefined | FastifySchema> = {
   [AppRoute.HOME]: undefined,
-  [AppRoute.SET_THEME]: {
+  [AppRoute.THEME_SET_SCHEME_ACTION]: {
     params: {
       type: "object",
       required: ["themeScheme"],

...
@@ -501,11 +503,11 @@ const RootAppRouter: AppRouter = () => {
       <></>
       <Router.Group type={AppRouterGroup.API}>
         <Router.Route
-          name={AppRoute.SET_THEME}
+          name={AppRoute.THEME_SET_SCHEME_ACTION}
           method={"GET"}
           path={"/theme/:themeScheme"}
-          schema={AppRoutesSchemas[AppRoute.SET_THEME]}
-          handler={ThemeController.getTheme}
+          schema={AppRoutesSchemas[AppRoute.THEME_SET_SCHEME_ACTION]}
+          handler={ThemeController.setThemeSchemeAction}
         />
         {/* --- */}
         <Router.Route