feat(reviews): add reviews route

allows seeing all reviews with optional filters.
works sans JS as well

closes https://github.com/zyachel/libremdb/issues/25
closes https://codeberg.org/zyachel/libremdb/issues/19
This commit is contained in:
zyachel
2024-03-31 15:37:44 +05:30
parent cf71cd39e1
commit dc42b3204c
29 changed files with 1053 additions and 31 deletions

View File

@ -81,18 +81,13 @@ export const AppError = class extends Error {
}
};
export const cleanQueryStr = (
entries: [string, string][],
filterable = ['q', 's', 'exact', 'ttype']
) => {
let queryStr = '';
export const cleanQueryStr = (record: Record<string, string>, filterable: string[]) => {
const urlSearchParams = new URLSearchParams();
entries.forEach(([key, val], i) => {
if (!val || !filterable.includes(key)) return;
queryStr += `${i > 0 ? '&' : ''}${key}=${val.trim()}`;
filterable.forEach(key => {
if (record[key]) urlSearchParams.append(key, record[key].trim());
});
return queryStr;
return urlSearchParams.toString();
};
export const getResTitleTypeHeading = (