{"id":15015919,"url":"https://github.com/elwayman02/ember-data-github","last_synced_at":"2025-04-12T09:33:16.818Z","repository":{"id":31039979,"uuid":"34598603","full_name":"elwayman02/ember-data-github","owner":"elwayman02","description":"Ember Data library for the GitHub API","archived":false,"fork":false,"pushed_at":"2020-08-17T19:36:29.000Z","size":1799,"stargazers_count":47,"open_issues_count":9,"forks_count":38,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T23:25:56.996Z","etag":null,"topics":["ember","ember-addon","ember-data","emberjs","github","github-api"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elwayman02.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-26T05:01:42.000Z","updated_at":"2023-12-05T14:47:02.000Z","dependencies_parsed_at":"2022-08-30T02:40:20.555Z","dependency_job_id":null,"html_url":"https://github.com/elwayman02/ember-data-github","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elwayman02%2Fember-data-github","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elwayman02%2Fember-data-github/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elwayman02%2Fember-data-github/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elwayman02%2Fember-data-github/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elwayman02","download_url":"https://codeload.github.com/elwayman02/ember-data-github/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248545994,"owners_count":21122243,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ember","ember-addon","ember-data","emberjs","github","github-api"],"created_at":"2024-09-24T19:48:09.098Z","updated_at":"2025-04-12T09:33:16.792Z","avatar_url":"https://github.com/elwayman02.png","language":"JavaScript","readme":"# Ember Data Github\n\n[![Build Status](https://travis-ci.org/elwayman02/ember-data-github.svg?branch=master)](https://travis-ci.org/elwayman02/ember-data-github)\n[![Ember Observer Score](http://emberobserver.com/badges/ember-data-github.svg)](http://emberobserver.com/addons/ember-data-github)\n[![Code Climate](https://codeclimate.com/github/elwayman02/ember-data-github/badges/gpa.svg)](https://codeclimate.com/github/elwayman02/ember-data-github)\n\nEmber Data abstraction for the [GitHub REST API v3](https://developer.github.com/v3/).\n\n## Installation\n\n```\nember install ember-data-github\n```\n\n## Usage\n\nYou need to choose how you wish to authenticate your GitHub requests using OAuth. `ember-data-github` provides a simple\nand direct mechanism that is specific to itself. Alternatively, you can use a more general authentication framework like\n`ember-simple-auth`.\n\n### Authenticating Directly\n\nIf you already have a token to use the OAuth endpoints, such as a *Personal access token*, you must set the property\nnamed `githubAccessToken` on `github-session` service with the currently logged in user's GitHub access token.\n\n### Authenticating with `ember-simple-auth`\n\nIf you are using [ember-simple-auth](http://ember-simple-auth.com/) (ESA) to authenticate, perhaps with\n[torii](http://vestorly.github.io/torii) and ESA's `torii-provider`, you can authenticate by creating a github\nauthorizer and extending `ember-data-github`'s adapter for each model you use. See the respective addon docs and\n[GitHub's OAuth docs](https://developer.github.com/v3/oauth/) to set it up.\n\n\nOnce you have a token, the authorizer will look like\n```js\n// app/authorizers/github.js\n\nimport { inject as service } from '@ember/service';\nimport { isEmpty } from '@ember/utils';\nimport Base from 'ember-simple-auth/authorizers/base';\n\nexport default Base.extend({\n  session: service(),\n  authorize(sessionData, block) {\n    if (this.get('session.isAuthenticated') \u0026\u0026 !isEmpty(sessionData.access_token)) {\n      block('Authorization', `token ${sessionData.access_token}`);\n    }\n  }\n});\n```\nassuming `access_token` is the name of the property containing the token. This automatically injects the `Authorization`\nheader into the API requests using ESA mechanisms.\n\nAn extended adapter for `github-user` would look like\n```js\n// app/adapters/github-user.js\n\nimport GitHubUserAdapter from 'ember-data-github/adapters/github-user';\nimport DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';\n\nexport default GitHubUserAdapter.extend(DataAdapterMixin, {\n  authorizer: 'authorizer:github'\n});\n```\n\n### Retrieving GitHub Data\n\n#### [Users](https://developer.github.com/v3/users/)\n\n##### [Get the current authenticated user](https://developer.github.com/v3/users/#get-the-authenticated-user)\n```js\nthis.get('store').findRecord('github-user', '#');\n```\n\n##### [Get a single user](https://developer.github.com/v3/users/#get-a-single-user)\n```js\nthis.get('store').findRecord('github-user', 'jimmay5469'); // get a user by user login\nthis.get('store').findRecord('github-user', 917672); // get a user by user id\n```\n\n#### [Repositories](https://developer.github.com/v3/repos/)\n\n##### [Get](https://developer.github.com/v3/repos/#get)\n```js\nthis.get('store').findRecord('github-repository', 'jimmay5469/old-hash'); // get a repository by repository name\nthis.get('store').findRecord('github-repository', 34598603); // get a repository by repository id\n```\n\n##### [Get By User](https://developer.github.com/v3/repos/#list-user-repositories)\n```js\nthis.get('store').query('github-repository', { user: 'elwayman02' }); // get repositories owned by user\nthis.get('store').query('github-repository', { user: 'elwayman02', type: 'all' }); // get all repositories for user\nthis.get('store').query('github-repository', { user: 'elwayman02', sort: 'updated', direction: 'asc' }); // get repositories owned by user sorted by last updated, ascending\n```\n\n##### [Repository Contents](https://developer.github.com/v3/repos/contents/)\n\n##### [Get](https://developer.github.com/v3/repos/contents/#get-contents)\nNote: At this time we only support getting file contents.\n```js\nthis.get('store').queryRecord('github-repository-contents', { repo: 'jmar910/test-repo-yay', file: 'app.json' }); // get file contents from repo\n\n```\n\n##### [Branches](https://developer.github.com/v3/repos/branches/)\n\n###### [List branches](https://developer.github.com/v3/repos/branches/#list-branches)\n\n```js\nthis.get('store').query('github-branch', { repo: 'jimmay5469/old-hash' });\n```\n\n###### [Get](https://developer.github.com/v3/repos/branches/#get-branch)\n```js\nthis.get('store').findRecord('github-branch', 'jimmay5469/old-hash/branches/master'); // get a branch\nthis.get('store').queryRecord('github-branch', { repo: 'jimmay5469/old-hash', branch: 'master' }); // get a specific branch\n```\n\n##### [Releases](https://developer.github.com/v3/repos/releases/)\n\n###### [List releases for a repository](https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository)\n```js\nthis.get('store').query('github-release', { repo: 'jimmay5469/old-hash' });\n```\n\n###### [Get a single release](https://developer.github.com/v3/repos/releases/#get-a-single-release)\n```js\nthis.get('store').queryRecord('github-release', { repo: 'jimmay5469/old-hash', releaseId: 1 });\n```\n\n##### [Commits](https://developer.github.com/v3/repos/commits/)\n\n###### [Compate two commits](https://developer.github.com/v3/repos/commits/#compare-two-commits)\n\n```js\nthis.get('store').queryRecord('github-compare', { repo: 'jimmay5469/old-hash', base: '1234', head: '5678' });\n```\n\n#### [Pull Requests](https://developer.github.com/v3/pulls/)\n\n##### [List pull requests](https://developer.github.com/v3/pulls/#list-pull-requests)\n```js\nthis.get('store').query('github-pull', { repo: 'jimmay5469/old-hash' });\n```\n\n##### [Get a single pull request](https://developer.github.com/v3/pulls/#get-a-single-pull-request)\n```js\nthis.get('store').queryRecord('github-pull', { repo: 'jimmay5469/old-hash', pullId: 1 });\n```\n#### [GitHub Organizations](https://developer.github.com/v3/orgs/)\n\n##### [Get an organizaton](https://developer.github.com/v3/orgs/#get-an-organization)\n```js\nthis.get('store').findRecord('github-organization', { org: 'my-org' });\n```\n\n##### [Get organization members](https://developer.github.com/v3/orgs/members/#members-list)\n```js\nthis.get('store').query('github-members', { org: 'my-org' })\n```\n\n#### [Git Blobs](https://developer.github.com/v3/git/blobs/)\n\n##### [Get a blob](https://developer.github.com/v3/git/blobs/#get-a-blob)\n\n```js\nthis.get('store').queryRecord('github-blob', { repo: 'jimmay5469/old-hash', sha: '47c5438403ca875f170db2aa07d1bfa3689406e3' });\n```\n#### [Git Trees](https://developer.github.com/v3/git/trees/)\n\n##### [Get a Tree](https://developer.github.com/v3/git/trees/#get-a-tree)\n\n```js\nthis.get('store').queryRecord('github-tree', { repo: 'jimmay5469/old-hash', sha: '47c5438403ca875f170db2aa07d1bfa3689406e3' });\n```\n\n## Testing with Mirage\n\nThis addon uses [ember-cli-mirage](http://www.ember-cli-mirage.com/) in its tests.  It is often beneficial for consuming apps to be able to re-use the factories and models defined in mirage, so if you would like to use these in your tests you can add the `mirage-support` object to your `ember-cli-build.js` file:\n\n```\nmodule.exports = function(defaults) {\n  let app = new EmberApp(defaults, {\n    ...\n    'mirage-support': {\n      includeAll: true\n    }\n    ...\n  });\n\n  return app.toTree();\n};\n```\n\n\nAs long as `ember-cli-mirage` is not disabled, the files in this addon's `mirage-support` directory will be merged with the consuming app's namespace, and be made available to that mirage context.\nThe `'mirage-support'` key has 3 options:\n\nKey | Type | Description\n--- | --- | ---\n`includeAll` | `Boolean` | If `true`, includes the full `mirage-support` tree, i.e. no-brainer just use it all.\n`exclude` | _{Array of `GlobStrings,RegExps,Functions`}_ | This value gets passed directly to `broccoli-funnel`, *only* if `includeAll` is specified. Allows for excluding certain files from import.\n`include` | _{Array of `GlobStrings,RegExps,Functions`}_ | Passed dirctly to `broccoli-funnel`. Allows to pick only certain files to be imported into app namespace.\n\n\n## Contributing\n\n### Installation\n\n* `git clone git@github.com:elwayman02/ember-data-github.git`\n* `cd ember-data-github`\n* `yarn`\n\n### Running\n\n* `ember serve`\n* Visit your app at [http://localhost:4200](http://localhost:4200).\n\n### Running Tests\n\n* `ember test` – Runs the test suite on the current Ember version\n* `ember test --server` – Runs the test suite in \"watch mode\"\n* `ember try:each` – Runs the test suite against multiple Ember versions\n\n### Building\n\n* `ember build`\n\nFor more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felwayman02%2Fember-data-github","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felwayman02%2Fember-data-github","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felwayman02%2Fember-data-github/lists"}