new GitHubAPI()
The GitHubAPI backend is a lambda function invoked via Netlify's functions system. It receives HTTP requests and conducts GitHub API calls based on the instructions in the request header and data provided in the body.
Methods
-
async, static checkResponseCode(response, code, method) → {Promise.<object>}
-
Check a response code matches one of the expected codes.
Parameters:
Name Type Default Description responseobject GitHub API response. codenumber | Array.<number> status code to check for. methodstring GET request method. Returns:
Promise.<object> -
async, static copyFile(event) → {Promise.<Object>}
-
Copy a file from one repository to another, and return the copy.
Parameters:
Name Type Description eventObject Returns:
Promise.<Object> -
async, static createRepository(event) → {Object}
-
Create a repository on GitHub for the currently authorised user.
Parameters:
Name Type Description eventobject request details. Returns:
Object -
async, static deleteFile(event) → {Object}
-
Delete a file via github commit.
Parameters:
Name Type Description eventobject request details. Returns:
Object -
async, static findRepositories(event) → {Object}
-
Look up the repositories.
Parameters:
Name Type Description eventReturns:
Object -
async, static findRepositoryFiles(event) → {Object}
-
Find all the files in a given repository.
Parameters:
Name Type Description eventReturns:
Object -
async, static getLastBuild(event) → {Promise.<{statusText: string, body: string, statusCode: number}>}
-
Retrieve the build status report for the last GitHub Pages build attempt.
Parameters:
Name Type Description eventobject Should have body JSON string with repository URL and GitHub access token. Returns:
Promise.<{statusText: string, body: string, statusCode: number}> -
async, static getTopics(event) → {Promise.<Object>}
-
Get the topics associated with a repository.
Parameters:
Name Type Description eventObject Returns:
Promise.<Object> -
async, static getUserDetails(event) → {Object}
-
Get the GitHub user details.
Parameters:
Name Type Description eventobject request details. Returns:
Object -
async, static main(event, context, callback)
-
Process requests from a client.
Parameters:
Name Type Description eventobject request details. contextobject environment details. callbackreturnResponse function to send the response to the client. -
static OK(obj) → {Object}
-
Send an OK response.
Parameters:
Name Type Description objobject Body content to be JSON.stringified(). Returns:
Object -
async, static pullItem(event) → {Object}
-
Pull an item from GitHub by its URL.
Parameters:
Name Type Description eventReturns:
Object -
async, static pushFile(event) → {Object}
-
Replace a file with a new version via github commit.
Parameters:
Name Type Description eventobject request details. Returns:
Object -
async, static redeemCode(event) → {Object}
-
Send a code to GitHub and request a token in exchange.
Parameters:
Name Type Description eventobject request details. Returns:
Object -
async, static setTopics(event) → {Object}
-
Set the topics on a newly created workshop so we can check custom repository submissions' eligibility easily.
Parameters:
Name Type Description eventobject request details. Returns:
Object