Last active
June 12, 2021 01:27
-
-
Save dhmlau/438f91f7578424d57f2fc972ebee1987 to your computer and use it in GitHub Desktop.
DataSource with REST Connector - GitHub API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {inject, lifeCycleObserver, LifeCycleObserver} from '@loopback/core'; | |
import {juggler} from '@loopback/repository'; | |
const config = { | |
name: 'githubds', | |
connector: 'rest', | |
baseURL: 'https://api.github.ibm.com', | |
crud: false, | |
options: { | |
headers: { | |
accept: 'application/json', | |
Authorization: process.env.TOKEN, | |
'User-Agent': 'loopback4-example-github', | |
'X-RateLimit-Limit': 5000, | |
'content-type': 'application/json' | |
} | |
}, | |
operations: [ | |
{ | |
template: { | |
method: 'GET', | |
fullResponse: true, | |
url: 'https://api.github.com/search/issues?q=repo:{repo}+label:"{label}"' | |
}, | |
functions: { | |
getIssuesByLabel: ['repo','label'] | |
} | |
}, { | |
template: { | |
method: 'GET', | |
fullResponse: true, | |
url: '{url}' | |
}, | |
functions: { | |
getIssuesByURL: ['url'] | |
} | |
}, { | |
template: { | |
method: 'GET', | |
fullResponse: true, | |
url: 'https://api.github.com/search/issues?q=repo:{repo}+{querystring}' | |
}, | |
functions: { | |
getIssuesWithQueryString: ['repo','querystring'] | |
} | |
} | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment