fix(code_highlight): load CSR languages correctly
+ 8
- 5
@@ -27,6 +27,7 @@ import InternalErrorView, {
   InternalErrorViewProps,
 } from "./views/InternalErrorView";
 // app
+import { AppRouteParams } from "./routes.defs";
 import { Const } from "./const";
 import { Env } from "./env";
 import { codeAnalysisPlugin, cryptoPlugin, prismaPlugin } from "./plugins";

...
@@ -38,7 +39,7 @@ import {
   makeRequestHandler,
 } from "./utils/server";
 
-let server: null | AppServer = null;
+let server: null | AppServer<AppRouteParams> = null;
 
 async function main(): Promise<AppServer> {
   const env = getEnv();

...
@@ -184,6 +185,7 @@ async function main(): Promise<AppServer> {
         src: `/register-imsw.js`,
         type: "module",
       },*/
+      // (Prism.JS) Client-side config
       {
         id: "prism.js-config",
         type: "application/javascript",

...
@@ -192,22 +194,22 @@ async function main(): Promise<AppServer> {
   window.Prism.manual = true;
   window.Prism.plugins.autoloader = {
     use_minifed: ${env === "production" ? "true" : "false"},
-    languages_path: "/public/assets/prism/components/",
+    languages_path: "${publicBaseUrl}/assets/prism/components/",
   };
 }`,
       },
     ],
     setupServerBeforeRoutes(s) {
-      // add a preHandler to warn against bad localhost usage (so cookies works)
+      // add a preHandler to warn against bad localhost usage (so cookies works in dev too)
       s.addHook("preHandler", localAppDomainPreHandler);
 
-      // ensure strings do not leak server path.
+      // function that ensure strings do not leak server/internal paths in error messages
       const cleanupFastifyError = (error: Error | FastifyError) => {
         error.message = error.message.replaceAll(Paths.ROOT_FOLDER, "");
         error.stack = error.stack?.replaceAll(Paths.ROOT_FOLDER, "");
       };
 
-      // load Prism languages/grammars to enable SSR syntax highlighting
+      // (Prism.JS) setup languages in the server side
       try {
         loadPrismJsLanguages();
       } catch (err) {

...
@@ -247,6 +249,7 @@ async function main(): Promise<AppServer> {
 
       // register the crypto plugin
       s.register(cryptoPlugin).after(() => {
+        // make a git service instance
         const gitService = makeGitServerService({
           cryptoService: s.cryptoService,
           request: {