Skip to content

Commit

Permalink
chore(webui): fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bambanah committed Oct 31, 2024
1 parent 48ec567 commit 859949b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
10 changes: 5 additions & 5 deletions webui/src/server/routes/api/get/albumSearch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Deezer } from "deezer-sdk";
import type { RequestHandler } from "express";
import { sessionDZ } from "../../../deemixApp.js";
import type { ApiHandler } from "../../../types.js";
import { sessionDZ } from "@/deemixApp.js";
import type { ApiHandler } from "@/types.js";

export interface RawAlbumQuery {
term: string;
Expand Down Expand Up @@ -29,13 +29,13 @@ const handler: RequestHandler<any, any, any, RawAlbumQuery> = async (
const dz = sessionDZ[req.session.id];

if (!req.query) {
return res.status(400).send();
res.status(400).send();
}

const { term, start, nb } = parseQuery(req.query);

if (!term || term.trim() === "") {
return res.status(400).send();
res.status(400).send();
}

const results = await dz.gw.search_music(term, "ALBUM", {
Expand All @@ -52,7 +52,7 @@ const handler: RequestHandler<any, any, any, RawAlbumQuery> = async (
total: albums.length,
};

return res.send(output);
res.send(output);
};

export const apiHandler = { path, handler };
Expand Down
10 changes: 4 additions & 6 deletions webui/src/server/routes/api/get/analyzeLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const handler: RequestHandler<ResBody, any, any, AnalyzeQuery> = async (
) => {
try {
if (!req.query || !req.query.term) {
return res
res
.status(400)
.send({ errorMessage: "No term specified", errorCode: "AL01" });
}
Expand All @@ -37,14 +37,12 @@ const handler: RequestHandler<ResBody, any, any, AnalyzeQuery> = async (
const apiMethod = linkType === "track" ? "get_track" : "get_album";
const resBody: ResBody = await dz.api[apiMethod](linkId);

return res.status(200).send(resBody);
res.status(200).send(resBody);
}

return res
.status(400)
.send({ errorMessage: "Not supported", errorCode: "AL02" });
res.status(400).send({ errorMessage: "Not supported", errorCode: "AL02" });
} catch (error) {
return res.status(500).send({
res.status(500).send({
errorMessage: "The server had a problem. Please try again",
errorObject: error,
errorCode: "AL03",
Expand Down
2 changes: 1 addition & 1 deletion webui/src/server/routes/api/get/getChartTracks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const handler: RequestHandler<any, any, any, RawChartTracksQuery> = async (
index,
limit,
});
return res.status(200).send(response);
res.status(200).send(response);
} catch (error) {
if (error instanceof BadRequestError) {
logger.error(error.message);
Expand Down
2 changes: 1 addition & 1 deletion webui/src/server/routes/api/get/newReleases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const handler: ApiHandler["handler"] = async (req, res) => {
total: albums.length,
};

return res.send(output);
res.send(output);
};

const apiHandler: ApiHandler = { path, handler };
Expand Down
4 changes: 2 additions & 2 deletions webui/src/server/routes/api/post/changeAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const handler: RequestHandler<any, any, any, ChangeAccountQuery> = (
res
) => {
if (!req.query || !req.query.child) {
return res
res
.status(400)
.send({ errorMessage: "No child specified", errorCode: "CA01" });
}
Expand All @@ -26,7 +26,7 @@ const handler: RequestHandler<any, any, any, ChangeAccountQuery> = (

const accountData = dz.changeAccount(accountNum);

return res.status(200).send(accountData);
res.status(200).send(accountData);
};

const apiHandler: ApiHandler = { path, handler };
Expand Down
10 changes: 5 additions & 5 deletions webui/src/server/routes/api/post/loginArl.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Deezer } from "deezer-sdk";
import type { RequestHandler } from "express";
import { DeemixApp, sessionDZ } from "@/deemixApp.js";
import { logger } from "@/helpers/logger.js";
import {
resetLoginCredentials,
saveLoginCredentials,
} from "@/helpers/loginStorage.js";
import { type ApiHandler } from "@/types.js";
import { Deezer } from "deezer-sdk";
import type { RequestHandler } from "express";

export interface RawLoginArlBody {
arl: string;
Expand All @@ -33,11 +33,11 @@ const handler: RequestHandler<any, any, RawLoginArlBody, any> = async (
const isSingleUser: boolean = req.app.get("isSingleUser");

if (!req.body) {
return res.status(400).send();
res.status(400).send();
}

if (!req.body.arl) {
return res.status(400).send();
res.status(400).send();
}

const loginParams: { arl: string; child?: number } = { arl: req.body.arl };
Expand Down Expand Up @@ -87,7 +87,7 @@ const handler: RequestHandler<any, any, RawLoginArlBody, any> = async (
arl: returnValue.arl,
});
} else if (isSingleUser) resetLoginCredentials();
return res.status(200).send(returnValue);
res.status(200).send(returnValue);
};

const apiHandler = { path, handler };
Expand Down

0 comments on commit 859949b

Please sign in to comment.