Skip to content

Commit

Permalink
ref: move manual search
Browse files Browse the repository at this point in the history
  • Loading branch information
Sv443 committed Nov 19, 2024
1 parent 6c7238f commit 35aa013
Showing 5 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/routes/album.ts
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 0 additions & 2 deletions src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -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();
14 changes: 0 additions & 14 deletions src/routes/manualSearch.ts

This file was deleted.

14 changes: 14 additions & 0 deletions src/routes/search.ts
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 0 deletions src/routes/translations.ts
Original file line number Diff line number Diff line change
@@ -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";

0 comments on commit 35aa013

Please sign in to comment.