Skip to content

Commit c52d3c5

Browse files
committed
fix: update search payload
Signed-off-by: rajput-hemant <[email protected]>
1 parent 4d0962c commit c52d3c5

File tree

7 files changed

+37
-14
lines changed

7 files changed

+37
-14
lines changed

bun.lockb

-11.5 KB
Binary file not shown.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"lint": "eslint src --ext ts,json --report-unused-disable-directives --max-warnings 0",
1414
"fmt": "prettier --write \"**/*.{ts,json}\" --cache",
1515
"fmt:check": "prettier --check \"**/*.{ts,json}\" --cache",
16-
"prepare": "husky install"
16+
"prepare": "husky"
1717
},
1818
"prettier": {
1919
"endOfLine": "lf",

src/payloads/search.payload.ts

+23-2
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,12 @@ export function allSearchPayload(s: AllSearchRequest): AllSearchResponse {
107107
album,
108108
ctr,
109109
position,
110-
more_info: { language, primary_artists, singers, triller_available },
110+
more_info,
111111
} = s;
112112

113+
const { language, primary_artists, singers, triller_available } =
114+
more_info!;
115+
113116
return {
114117
id,
115118
name: decode(title),
@@ -234,9 +237,27 @@ export function allSearchPayload(s: AllSearchRequest): AllSearchResponse {
234237
album,
235238
ctr,
236239
position,
237-
more_info: { language, primary_artists, singers, triller_available },
240+
more_info,
238241
} = t;
239242

243+
if (!more_info) {
244+
return {
245+
id,
246+
name: decode(title),
247+
subtitle: decode(description),
248+
type,
249+
image: createImageLinks(image),
250+
description,
251+
url,
252+
album,
253+
ctr,
254+
position,
255+
};
256+
}
257+
258+
const { primary_artists, singers, triller_available, language } =
259+
more_info;
260+
240261
return {
241262
id,
242263
name: decode(title),

src/routes/get.route.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ get.get("/footer-details", async (c) => {
232232
query: { language: validLangs(lang), p, n },
233233
});
234234

235-
if (!result.playlist.length) {
236-
throw new Error(
237-
"Failed to fetch footer details, please provide a valid language"
238-
);
239-
}
235+
// if (!result.playlist.length) {
236+
// throw new Error(
237+
// "Failed to fetch footer details, please provide a valid language"
238+
// );
239+
// }
240240

241241
if (parseBool(raw)) return c.json(result);
242242

src/routes/search.route.ts

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ search.get("/", async (c) => {
5959
return c.json(result);
6060
}
6161

62+
console.log({ result });
63+
6264
const payload: CAllSearchResponse = {
6365
status: "Success",
6466
message: "✅ Search results fetched successfully",

src/types/search.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export type AllSearchRequest = {
7979
video_available: boolean;
8080
triller_available: boolean;
8181
language: string;
82-
};
82+
} | null;
8383
}>;
8484
playlists: A<{
8585
id: string;
@@ -207,9 +207,9 @@ export type AllSearchResponse = {
207207
url: string;
208208
type: string;
209209
position: number;
210-
primary_artists: string;
211-
singers: string;
212-
language: string;
210+
primary_artists?: string;
211+
singers?: string;
212+
language?: string;
213213
}>;
214214
playlists: A<{
215215
id: string;

tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
"strict": true,
1515
"noUnusedLocals": true,
1616
"noUnusedParameters": true,
17-
"noFallthroughCasesInSwitch": true,
17+
"noFallthroughCasesInSwitch": true
1818

1919
/* path aliases */
2020
// "baseUrl": "./",
2121
// "paths": {
2222
// "@/*": ["src/*"]
2323
// }
2424
},
25-
"include": ["_api", "src", "test", ".env"],
25+
"include": ["_api", "src", "test", ".env"]
2626
}

0 commit comments

Comments
 (0)