Skip to content

Commit 1063504

Browse files
Added the proper types to the top-tracks endpoint function
1 parent c6c400e commit 1063504

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/routes/api/top-tracks/index.json.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
1-
import { getTopTracks } from '$lib/utils/spotify';
1+
import type { ITopTrack } from '$models/interfaces/itop-track.interface';
2+
import { getTopTracks } from '$utils/spotify';
23

34
/** @type {import('@sveltejs/kit').RequestHandler} */
4-
export async function get({ query }) {
5+
export async function get({
6+
query,
7+
}: {
8+
query: URLSearchParams;
9+
}): Promise<
10+
| {
11+
status: number;
12+
headers?: {
13+
[key: string]: string;
14+
};
15+
body?: string;
16+
}
17+
| {
18+
status: number;
19+
headers: {
20+
[key: string]: string;
21+
};
22+
body: ITopTrack[];
23+
}
24+
> {
525
const limit = Number(query.get('limit') ?? 10);
626

727
if (Number.isNaN(limit)) {

0 commit comments

Comments
 (0)