All sources
npm Trending
Developer v1.0.0Popular and trending packages on npm
@codytseng #npm #packages #javascript
Configuration
| Name | Key | Type | Required | Default | Description |
|---|---|---|---|---|---|
| Keyword | KEYWORD | string | No | typescript | Search keyword, e.g. typescript, react, cli, ai |
Source Code
version: 1.0.0
name: npm Trending
description: Popular and trending packages on npm
author: codytseng
author_url: https://github.com/codytseng
category: Developer
tags:
- npm
- packages
- javascript
config:
- key: KEYWORD
name: Keyword
type: string
required: false
default: typescript
description: "Search keyword, e.g. typescript, react, cli, ai" version: 1.0.0
name: npm Trending
description: Popular and trending packages on npm
author: codytseng
author_url: https://github.com/codytseng
category: Developer
tags:
- npm
- packages
- javascript
config:
- key: KEYWORD
name: Keyword
type: string
required: false
default: typescript
description: "Search keyword, e.g. typescript, react, cli, ai" module.exports = async (api) => {
const keyword = api.config.get("KEYWORD") || "typescript";
async function fetchData() {
const res = await api.fetch(
`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(keyword)}&popularity=1.0&quality=0.5&maintenance=0.0&size=250`,
);
if (!res.ok || !res.json) {
throw new Error(`Failed to fetch npm search results (HTTP ${res.status})`);
}
api.emit(
res.json.objects.map((obj) => {
const pkg = obj.package;
const author = pkg.publisher?.username
? ` · by ${pkg.publisher.username}`
: "";
return {
id: pkg.name,
title: `${pkg.name}@${pkg.version}`,
subtitle: `${pkg.description || ""}${author}`,
url: pkg.links.npm,
timestamp: pkg.date,
};
}),
);
}
await fetchData();
return {
refresh: fetchData,
};
}; module.exports = async (api) => {
const keyword = api.config.get("KEYWORD") || "typescript";
async function fetchData() {
const res = await api.fetch(
`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(keyword)}&popularity=1.0&quality=0.5&maintenance=0.0&size=250`,
);
if (!res.ok || !res.json) {
throw new Error(`Failed to fetch npm search results (HTTP ${res.status})`);
}
api.emit(
res.json.objects.map((obj) => {
const pkg = obj.package;
const author = pkg.publisher?.username
? ` · by ${pkg.publisher.username}`
: "";
return {
id: pkg.name,
title: `${pkg.name}@${pkg.version}`,
subtitle: `${pkg.description || ""}${author}`,
url: pkg.links.npm,
timestamp: pkg.date,
};
}),
);
}
await fetchData();
return {
refresh: fetchData,
};
};