or just include build/githubAPI.js in your projects the way you see fit :)
Show, Don't Tell
Let's see how to use githubapi.js. There are examples for you to look at and see how to use it.
The examples shows usage from the browser and from node.js. You can
find them in /examples/express/public.
using github authentication
It shows how to login/logout with the github authentication.
A logged in user will give profile information and access_token.
The access_token is given to github to authenticate the user.
It can be used from the browser or from node.js.
use github api thru a rest
There is example express routes called
githubapi-rest-examples. it provides a example of REST API on top of githubapi.js.
This is a good place to see how to use githubapi.js from node.js.
upload from browser
It upload files from the browser directly to gihub.
It is possible to upload from node.ns too, but uploading from the user's browser, save
bandwidth on servers.
It is a good place to see how to use githubapi.js from browser.
app.js is the usual
application for express server. It is a good place to see how to initialize the github authentication
in your own server.
Now, let's run the server. A server is required because github api requires authentications for many calls.
An authentication server is provided as examples in /examples/express,
coded with express as you may have guessed.
It run the authentication server and serve /examples/express/public as static.
First you need to authenticate yourself on github.
It will give permissions to example application.
Getting application's keys from github
You need to create register your application on github.
At the moment, it is in user -> setting -> applications -> register new application.
link
Get the clientID and clientSecret you see on top.
Then setup those value into your examples server. First, copy examples/expess/app_github_keys.sample.js into examples/expess/app_github_keys.js
Then replace the values by your own clientID/clientSecret.
And you are done.
How to run the example
Once you got the keys setup, launch the server this way and go to
http://127.0.0.1:8000/ with your browser
cd examples/express
make server
Makefile
make build - build the library
make minify - build the library and minify it
make server - launch dev server
make jsdoc - generate docs/api.md from jsdoc in /src
Motivation
This library is working well in my experience,
They are other wrapper for github api, i dont claim mine is better :)
The other libraries seemed good when i looked. be sure to check them out.
I had to implement my own github api wrapper.
It was a core part of a project.
So i had to really understand it, i could not rely
on a 3rd party library. This is why i reimplemented it.
TODO - Possible Improvements
Use conditional requests for github api calls and thus reduce rate limits
请发表评论