Skip to content

Commit 2e338d0

Browse files
committed
add missing files
1 parent 989289a commit 2e338d0

File tree

4 files changed

+86
-46
lines changed

4 files changed

+86
-46
lines changed

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
"dependencies": {
1313
"@ant-design/icons": "^5.6.1",
1414
"@ctrl/tinycolor": "^4.1.0",
15+
"@types/lodash": "^4.17.16",
1516
"antd": "^5.24.4",
1617
"axios": "^1.8.3",
18+
"lodash": "^4.17.21",
1719
"react": "^19.0.0",
1820
"react-dom": "^19.0.0",
1921
"semver": "^7.7.1"

src/index.css

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,10 @@
1313
-moz-osx-font-smoothing: grayscale;
1414
}
1515

16-
a {
17-
font-weight: 500;
18-
color: #646cff;
19-
text-decoration: inherit;
20-
}
21-
a:hover {
22-
color: #535bf2;
23-
}
24-
2516
body {
2617
margin: 0;
2718
display: flex;
2819
place-items: center;
2920
min-width: 320px;
3021
min-height: 100vh;
3122
}
32-
33-
h1 {
34-
font-size: 3.2em;
35-
line-height: 1.1;
36-
}
37-
38-
button {
39-
border-radius: 8px;
40-
border: 1px solid transparent;
41-
padding: 0.6em 1.2em;
42-
font-size: 1em;
43-
font-weight: 500;
44-
font-family: inherit;
45-
background-color: #1a1a1a;
46-
cursor: pointer;
47-
transition: border-color 0.25s;
48-
}
49-
button:hover {
50-
border-color: #646cff;
51-
}
52-
button:focus,
53-
button:focus-visible {
54-
outline: 4px auto -webkit-focus-ring-color;
55-
}
56-
57-
@media (prefers-color-scheme: light) {
58-
:root {
59-
color: #213547;
60-
background-color: #ffffff;
61-
}
62-
a:hover {
63-
color: #747bff;
64-
}
65-
button {
66-
background-color: #f9f9f9;
67-
}
68-
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import axios from "axios";
2+
3+
export interface NpmPackageSuggestion {
4+
name: string;
5+
version: string;
6+
description: string;
7+
score: {
8+
final: number;
9+
detail: {
10+
quality: number;
11+
popularity: number;
12+
maintenance: number;
13+
};
14+
};
15+
}
16+
17+
interface NpmsApiResponse {
18+
package: {
19+
name: string;
20+
version: string;
21+
description: string;
22+
links: {
23+
npm: string;
24+
homepage?: string;
25+
repository?: string;
26+
};
27+
};
28+
score: {
29+
final: number;
30+
detail: {
31+
quality: number;
32+
popularity: number;
33+
maintenance: number;
34+
};
35+
};
36+
searchScore: number;
37+
}
38+
39+
/**
40+
* Fetches package suggestions from npms.io API
41+
* @param query Search query string
42+
* @param size Number of suggestions to return (default: 10)
43+
* @returns Array of package suggestions
44+
*/
45+
export const fetchPackageSuggestions = async (
46+
query: string,
47+
size: number = 10
48+
): Promise<NpmPackageSuggestion[]> => {
49+
if (!query.trim()) {
50+
return [];
51+
}
52+
53+
try {
54+
const response = await axios.get<NpmsApiResponse[]>(
55+
`https://api.npms.io/v2/search/suggestions`,
56+
{
57+
params: { q: query, size },
58+
}
59+
);
60+
61+
// Transform the response to our desired format
62+
return response.data.map((item: NpmsApiResponse) => ({
63+
name: item.package.name,
64+
version: item.package.version,
65+
description: item.package.description,
66+
score: item.score,
67+
}));
68+
} catch (error) {
69+
console.error("Error fetching package suggestions:", error);
70+
return [];
71+
}
72+
};

0 commit comments

Comments
 (0)