在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:microsoft/ghrequestor开源软件地址:https://github.com/microsoft/ghrequestor开源编程语言:JavaScript 100.0%开源软件介绍:GHRequestorA simple, resilient GitHub API client that:
GHRequestor is a relatively low-level facility intended for traversing large graphs of GitHub resources. Its primary usecase is GHCrawler, an engine that walks subsections of GitHub collecting related resources. This not intended to replace great modules like octonode or github. UsageThe API is modelled after the standard node Simple GET of a single page const ghrequestor = require('ghrequestor');
ghrequestor.get('https://api.github.com/repos/Microsoft/ghrequestor').then(response => {
console.log(response.body);
}); GET a resource that spans multiple pages and flatten the responses into a single array. Notice the result includes
an activity property detailing the requests and responses that went into getting the final result. You can swap const ghrequestor = require('ghrequestor');
ghrequestor.getAll('https://api.github.com/repos/Microsoft/ghrequestor/commits').then(result => {
console.log(result.length);
console.log(result.activity.length);
console.log(result.activity[0].attempts);
}); GET with a set of etags and a content supplier that has the etagged resources. With this you can integrate an in-memory or persistent cache of GitHub resources and let ghrequestor optimize the fetching and your use of API tokens. It's nicer on the GitHub infrastructure as well. Notice that the etag value include the const ghrequestor = require('ghrequestor');
const url = <some url>;
ghrequestor.getAllResponses(url, { etags: ['"42"']}).then(responses => {
const supplier = url => { return yourContentLookupCode(); };
return ghrequestor.flattenResponses(responses, supplier).then(results => {
console.log(results.length);
});
}); AuthenticationAuthentication is handled the same as with Node's ghrequestor.get(url, { authorization: 'token <my token here>' }); Or const requestorTemplate = ghrequestor.defaults({ authorization: 'token <my token here>' });
requestorTemplate.get(url); Loggingghrequestor takes a winston-style logger as a const winston = require('winston');
const requestorTemplate = ghrequestor.defaults({ logger: winston });
requestorTemplate.get(url); ContributingThis project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论