Sv443 пре 5 месеци
родитељ
комит
35aa01368d
5 измењених фајлова са 18 додато и 16 уклоњено
  1. 2 0
      src/routes/album.ts
  2. 0 2
      src/routes/index.ts
  3. 0 14
      src/routes/manualSearch.ts
  4. 14 0
      src/routes/search.ts
  5. 2 0
      src/routes/translations.ts

+ 2 - 0
src/routes/album.ts

@@ -3,12 +3,14 @@ import { paramValid, respond } from "../utils";
 import { getAlbum } from "../songData";
 
 export function initAlbumRoutes(router: Router) {
+  //#region /album
   router.get("/album", (req, res) => {
     const format: string = req.query.format ? String(req.query.format) : "json";
 
     return respond(res, "clientError", "No song ID provided", format);
   });
 
+  //#region /album/:songId
   router.get("/album/:songId", async (req, res) => {
     try {
       const { songId } = req.params;

+ 0 - 2
src/routes/index.ts

@@ -4,13 +4,11 @@ import packageJson from "../../package.json";
 import { initSearchRoutes } from "./search";
 import { initTranslationsRoutes } from "./translations";
 import { initAlbumRoutes } from "./album";
-import { initManualSearchRoutes } from "./manualSearch";
 
 const routeFuncs: ((router: Router) => unknown)[] = [
   initSearchRoutes,
   initTranslationsRoutes,
   initAlbumRoutes,
-  initManualSearchRoutes,
 ];
 
 const router = Router();

+ 0 - 14
src/routes/manualSearch.ts

@@ -1,14 +0,0 @@
-import { Router } from "express";
-
-export function initManualSearchRoutes(router: Router) {
-  router.get("/manual-search", (_req, res) => {
-    res.sendFile("index.html", {
-      root: "public",
-      dotfiles: "deny",
-      headers: {
-        "Content-Type": "text/html; charset=utf-8",
-      },
-      maxAge: 1000 * 60 * 60 * 24 * 7,
-    });
-  });
-}

+ 14 - 0
src/routes/search.ts

@@ -3,6 +3,7 @@ import { paramValid, respond } from "../utils";
 import { getMeta } from "../songData";
 
 export function initSearchRoutes(router: Router) {
+  //#region /search
   router.get("/search", async (req, res) => {
     try {
       const { q, artist, song, format: fmt } = req.query;
@@ -35,6 +36,7 @@ export function initSearchRoutes(router: Router) {
     }
   });
 
+  //#region /search/top
   router.get("/search/top", async (req, res) => {
     try {
       const { q, artist, song, format: fmt } = req.query;
@@ -63,4 +65,16 @@ export function initSearchRoutes(router: Router) {
       return respond(res, "serverError", `Encountered an internal server error${err instanceof Error ? err.message : ""}`, "json");
     }
   });
+
+  //#region /search/manual
+  router.get("/search/manual", (_req, res) => {
+    res.sendFile("index.html", {
+      root: "public",
+      dotfiles: "deny",
+      headers: {
+        "Content-Type": "text/html; charset=utf-8",
+      },
+      maxAge: 1000 * 60 * 60 * 24 * 7,
+    });
+  });
 }

+ 2 - 0
src/routes/translations.ts

@@ -3,12 +3,14 @@ import { paramValid, respond } from "../utils";
 import { getTranslations } from "../songData";
 
 export function initTranslationsRoutes(router: Router) {
+  //#region /translations
   router.get("/translations", (req, res) => {
     const format: string = req.query.format ? String(req.query.format) : "json";
 
     return respond(res, "clientError", "No song ID provided", format);
   });
 
+  //#region /tr/:songId
   router.get("/translations/:songId", async (req, res) => {
     const { format: fmt } = req.query;
     const format: string = fmt ? String(fmt) : "json";