Skip to content

Commit 48b87fe

Browse files
committed
fix: fix api fields
1 parent a401dc5 commit 48b87fe

File tree

2 files changed

+59
-57
lines changed

2 files changed

+59
-57
lines changed

lib/images.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export function makeRequestSource(source: string) {
1212

1313
export async function request<T = any>(sources: string, init?: RequestInit) {
1414
const url = makeRequestSource(sources);
15+
1516
try {
1617
const serverResponse = await fetch(
1718
url,
@@ -27,7 +28,7 @@ export async function request<T = any>(sources: string, init?: RequestInit) {
2728
const jsonResponse = await serverResponse.json();
2829
return jsonResponse as T;
2930
} catch (e) {
30-
console.log(e);
31+
console.log('request error', url, e);
3132
}
3233
}
3334

@@ -44,7 +45,7 @@ export function queryImages(
4445
) {
4546
const query = {
4647
...payload,
47-
source: type,
48+
type: type,
4849
query: tag,
4950
};
5051
return request<{ total: number; results: ImageDetail[] }>(
@@ -73,7 +74,7 @@ export function queryImageOrgDetailWithTag(name: string, tags?: string) {
7374
});
7475
}
7576

76-
export function queryImageDetailTags(name: string) {
77+
export function queryImageTags(name: string) {
7778
return request<{ results: ImageDetailForTag[]; count: number }>(
7879
`v2/repositories/${name}/tags?${stringify({
7980
page: 1,

types/image.ts

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,75 @@
11
export enum SYSTEM {
22
LINUX = 'linux',
33
UNKNOWN = 'unknown',
4-
WINDOWS = 'windows'
4+
WINDOWS = 'windows',
55
}
66

77
export type OperatingSystem = {
8-
name: SYSTEM
9-
label: Uppercase<SYSTEM>
10-
}
8+
name: SYSTEM;
9+
label: Uppercase<SYSTEM>;
10+
};
1111

1212
export type Repository = {
13-
name: string
14-
namespace: string
15-
description: string
16-
type: ImageType
17-
pull_count: string
18-
is_automated: boolean
19-
is_official: boolean
20-
is_trusted: boolean
21-
last_pushed_at: string
22-
last_pulled_at: string
23-
}
13+
name: string;
14+
namespace: string;
15+
description: string;
16+
type: ImageType;
17+
pull_count: string;
18+
is_automated: boolean;
19+
is_official: boolean;
20+
is_trusted: boolean;
21+
last_pushed_at: string;
22+
last_pulled_at: string;
23+
};
2424

2525
export type Architecture = {
26-
name: string
27-
label: string
28-
}
26+
name: string;
27+
label: string;
28+
};
2929

3030
export type RatePlanItem = {
31-
id: string
32-
repositories: Repository[]
33-
operating_systems: OperatingSystem[]
34-
architectures: Architecture[]
35-
}
31+
id: string;
32+
repositories: Repository[];
33+
operating_systems: OperatingSystem[];
34+
architectures: Architecture[];
35+
};
3636

3737
export type CategoryItem = {
38-
slug: string
39-
name: string
40-
}
38+
slug: string;
39+
name: string;
40+
};
4141

42-
export type ImageType = 'store' | 'community' | 'image' | 'verified_publisher'
42+
export type ImageType = 'store' | 'community' | 'image' | 'verified_publisher';
4343

4444
export type ImageDetail = {
45-
id: string
46-
name: string
47-
slug: string
48-
type: ImageType
49-
created_at: string
50-
updated_at: string
51-
short_description: string
52-
source: ImageType
53-
star_count: number
54-
extension_reviewed: boolean
45+
id: string;
46+
name: string;
47+
slug: string;
48+
type: ImageType;
49+
created_at: string;
50+
updated_at: string;
51+
short_description: string;
52+
source: ImageType;
53+
star_count: number;
54+
extension_reviewed: boolean;
5555
logo_url: {
56-
large: string
57-
small: string
58-
}
59-
categories: CategoryItem[]
60-
rate_plans: RatePlanItem[]
61-
}
56+
large: string;
57+
small: string;
58+
};
59+
categories: CategoryItem[];
60+
rate_plans: RatePlanItem[];
61+
};
6262

6363
export type ImageDetailForTag = ImageDetail & {
64-
full_description: string
65-
hub_user: string
66-
namespace: string
67-
pull_count: number
68-
repository_type: ImageType
69-
star_count: number
70-
status: number
71-
user: string
72-
last_updated: string
73-
content_types: ImageType[]
74-
}
64+
full_description: string;
65+
hub_user: string;
66+
namespace: string;
67+
pull_count: number;
68+
repository_type: ImageType;
69+
star_count: number;
70+
status: number;
71+
user: string;
72+
last_updated: string;
73+
content_types: ImageType[];
74+
description: string;
75+
};

0 commit comments

Comments
 (0)