@swarnendu0123/github-stats
v1.0.12
Published
A npm package to get all the open pull request/issues in a CURD application
Downloads
4
Readme
github-stats (GitHub Statistics)
Get all your github issues and pull-request in one place.
Usefull Links:
- GitHub: https://github.com/Swarnendu0123/github-stats
- NPM: https://www.npmjs.com/package/@swarnendu0123/github-stats
Features:
getPulls(repoUrl)
: Function Get all the pull requests of a repositorygetIssues(repoUrl)
: Function Get all the issues of a repositorygetPulls(repoUrl, by)
: Function Get all the pull requests of a repository created by a specific usergetIssues(repoUrl, by)
: Function Get all the issues of a repository created by a specific userby (Optional)
: The user who created the pull request/issue . If not provided, it will return all the pull requests.
Installation:
Npm:
npm install @swarnendu0123/github-stats
Yarn:
yarn add @swarnendu0123/github-stats
if you are using Typescript, you can install the types for node:
Npm:
npm i --save-dev @types/node
Yarn:
yarn add --dev @types/node
Usage:
Promise Syntax:
const stats = require("@swarnendu0123/github-stats");
stats
.getIssues("https://github.com/oxiton-foundation/click-metrics")
.then((data) => {
console.log(data);
});
Async/Await Syntax:
const stats = require("@swarnendu0123/github-stats");
const myPulls = await stats.getPulls(
"https://github.com/oxiton-foundation/click-metrics"
);
console.log(myPulls);
const stats = require("@swarnendu0123/github-stats");
const myPulls = await stats.getPulls(
"https://github.com/oxiton-foundation/click-metrics",
"Swarnendu0123"
);
console.log(myPulls);
Output:
[
{
title: 'Example PR for checking. (Do not merge it or close it)',
url: 'https://github.com/oxiton-foundation/click-metrics/pull/9',
openedBy: 'Swarnendu0123',
issueLabel: [ 'level 4', 'OOSI' ],
status: 'open'
},
{
title: 'MINOR CHANGES',
url: 'https://github.com/oxiton-foundation/click-metrics/pull/8',
openedBy: 'Swarnendu0123',
issueLabel: [],
status: 'merged'
}
]
Using in a react app:
import React, { useEffect, useState } from "react";
import { getIssues } from "@swarnendu0123/github-stats";
function MyComponent() {
const [issues, setIssues] = useState([]);
useEffect(() => {
getIssues("https://github.com/oxiton-foundation/click-metrics").then(
(data) => {
setIssues(data);
}
);
}, []);
return (
<div>
{issues.map((index, issue) => (
<div key={index}>
<h1>{issue.title}</h1>
<p>{issue.url}</p>
<p>{issue.openedBy}</p>
<p>
{issue.issueLabel.map((label) => (
<span>{label}</span>
))}
</p>
<p>{issue.status}</p>
</div>
))}
</div>
);
}
export default MyComponent;
Keywords:
github-stats
github
stats
issues
pulls
github-issues
github-pulls
github-stats
github-api
github-issues-api
github-pulls-api
github-stats-api
github-issues-pulls
github-issues-pulls-stats
github-issues-pulls-stats-api
github-issues-pulls-stats-npm
github-issues-pulls-stats-npm-package
github-issues-pulls-stats-npm-package-api