Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-data-github

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-data-github - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

.idea/markdown-navigator.xml

26

addon/adapters/github-branch.js
import GithubAdapter from './github';
export default GithubAdapter.extend({
buildURL(type, id, snapshot) {
let builtURL = this._super(type, id, snapshot);
if (id) {
builtURL = builtURL.replace('branches', 'repos');
builtURL = builtURL.replace(/%2F/g, '/');
}
return builtURL;
urlForFindRecord(id, modelName, snapshot) {
return this._super(id, modelName, snapshot)
.replace('branches', 'repos')
.replace(/%2F/g, '/');
},
urlForQuery(query) {
const repo = query.repo;
delete query.repo;
return `${this.get('host')}/repos/${repo}/branches`;
},
urlForQueryRecord(query) {
const {repo, branch} = query;
delete query.repo;
delete query.branch;
return `${this.get('host')}/repos/${repo}/branches/${branch}`;
}
});
import GithubAdapter from './github';
export default GithubAdapter.extend({
buildURL(type, id, snapshot) {
let builtURL = this._super(type, id, snapshot);
return builtURL;
}
});
import GithubAdapter from './github';
export default GithubAdapter.extend({
buildURL(type, id, snapshot) {
let builtURL = this._super(type, id, snapshot);
if (id) {
builtURL = builtURL.replace('repositories', 'repos');
builtURL = builtURL.replace('%2F', '/');
}
return builtURL;
urlForFindRecord(id, modelName, snapshot) {
return this._super(id, modelName, snapshot)
.replace('repositories', 'repos')
.replace('%2F', '/');
}
});
import GithubAdapter from './github';
export default GithubAdapter.extend({
buildURL(type, id, snapshot) {
let builtURL = this._super(type, id, snapshot);
urlForFindRecord(id, modelName, snapshot) {
let builtURL = this._super(id, modelName, snapshot);
if (id === '#') {

@@ -7,0 +7,0 @@ builtURL = builtURL.replace('users/%23', 'user');

/*jshint node:true*/
'use strict';
module.exports = function (/* environment, appConfig */) {
module.exports = function(/* environment, appConfig */) {
return { };
};
{
"name": "ember-data-github",
"version": "0.2.0",
"version": "0.3.0",
"description": "Ember Data abstraction for the GitHub API",
"keywords": [
"ember-addon",
"ember-data",
"github",
"api"
],
"license": "MIT",
"author": "Jordan Hawker <hawker.jordan@gmail.com> (http://www.JordanHawker.com)",
"directories": {

@@ -9,2 +17,3 @@ "doc": "doc",

},
"repository": "git@github.com:elwayman02/ember-data-github.git",
"scripts": {

@@ -15,19 +24,15 @@ "build": "ember build",

},
"repository": "git@github.com:elwayman02/ember-data-github.git",
"engines": {
"node": ">= 0.10.0"
"dependencies": {
"ember-cli-babel": "^5.1.7"
},
"author": "Jordan Hawker <hawker.jordan@gmail.com> (http://www.JordanHawker.com)",
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.4.2",
"ember-cli": "2.7.0",
"broccoli-asset-rev": "^2.4.5",
"ember-cli": "2.10.0",
"ember-cli-app-version": "^2.0.0",
"ember-cli-content-security-policy": "0.5.0",
"ember-cli-dependency-checker": "^1.2.0",
"ember-cli-dependency-checker": "^1.3.0",
"ember-cli-eslint": "3.0.0",
"ember-cli-htmlbars": "^1.1.0",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-inject-live-reload": "^1.4.0",
"ember-cli-qunit": "^3.0.0",
"ember-cli-htmlbars-inline-precompile": "^0.3.3",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-qunit": "^3.0.1",
"ember-cli-release": "1.0.0-beta.2",

@@ -37,17 +42,11 @@ "ember-cli-sri": "^2.1.0",

"ember-cli-uglify": "^1.2.0",
"ember-data": "^2.7.0",
"ember-data": "^2.10.0",
"ember-disable-prototype-extensions": "^1.1.0",
"ember-export-application-global": "^1.0.5",
"ember-load-initializers": "^0.5.1",
"ember-export-application-global": "^1.1.1",
"ember-load-initializers": "^0.6.2",
"ember-resolver": "^2.0.3",
"loader.js": "^4.0.7"
"loader.js": "^4.0.10"
},
"keywords": [
"ember-addon",
"ember-data",
"github",
"api"
],
"dependencies": {
"ember-cli-babel": "^5.1.6"
"engines": {
"node": ">= 0.12.0"
},

@@ -54,0 +53,0 @@ "ember-addon": {

@@ -17,14 +17,63 @@ # Ember Data Github

In order to use OAuth endpoints you must set the property named `githubAccessToken` on `github-session` service with the currently logged in user's GitHub access token.
You need to choose how you wish to authenticate your GitHub requests using OAuth. `ember-data-github` provides a simple
and direct mechanism that is specific to itself. Alternatively, you can use a more general authentication framework like
`ember-simple-auth`.
Examples:
### Authenticating Directly
If you already have a token to use the OAuth endpoints, such as a *Personal access token*, you must set the property
named `githubAccessToken` on `github-session` service with the currently logged in user's GitHub access token.
### Authenticating with `ember-simple-auth`
If you are using [ember-simple-auth](http://ember-simple-auth.com/) (ESA) to authenticate, perhaps with
[torii](http://vestorly.github.io/torii) and ESA's `torii-provider`, you can authenticate by creating a github
authorizer and extending `ember-data-github`'s adapter for each model you use. See the respective addon docs and
[GitHub's OAuth docs](https://developer.github.com/v3/oauth/) to set it up.
Once you have a token, the authorizer will look like
```js
// app/authorizers/github.js
import Ember from 'ember';
import Base from 'ember-simple-auth/authorizers/base';
export default Base.extend({
session: Ember.inject.service(),
authorize(sessionData, block) {
if (this.get('session.isAuthenticated') && !Ember.isEmpty(sessionData.access_token)) {
block('Authorization', `token ${sessionData.access_token}`);
}
}
});
```
this.get('store').findRecord('githubUser', '#'); // get the current user
this.get('store').findRecord('githubUser', 'jimmay5469'); // get a user
this.get('store').findRecord('githubRepository', 'jimmay5469/old-hash'); // get a repository
this.get('store').findRecord('githubBranch, 'jimmay5469/old-hash/branches/master'); // get a branch
this.get('store').queryRecord('githubRelease', { repo: 'jimmay5469/old-hash', releaseId: 1 }) // get a specific release
this.get('store').query('githubRelease', { repo: 'jimmay5469/old-hash' }) // get a repo's releases
assuming `access_token` is the name of the property containing the token. This automatically injects the `Authorization`
header into the API requests using ESA mechanisms.
An extended adapter for `github-user` would look like
```js
// app/adapters/github-user.js
import GitHubUserAdapter from 'ember-data-github/adapters/github-user';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
export default GitHubUserAdapter.extend(DataAdapterMixin, {
authorizer: 'authorizer:github'
});
```
### Retrieving GitHub Data
The following examples show how to retrieve each supported GitHub entity as you might use it in your `model` hook.
```js
this.get('store').findRecord('github-user', '#'); // get the current user
this.get('store').findRecord('github-user', 'jimmay5469'); // get a user
this.get('store').findRecord('github-repository', 'jimmay5469/old-hash'); // get a repository
this.get('store').findRecord('github-branch', 'jimmay5469/old-hash/branches/master'); // get a branch
this.get('store').queryRecord('github-branch', { repo: 'jimmay5469/old-hash', branch: 'master' }); // get a specific branch
this.get('store').query('github-branch', { repo: 'jimmay5469/old-hash' }); // get a repo's branches
this.get('store').queryRecord('github-release', { repo: 'jimmay5469/old-hash', releaseId: 1 }); // get a specific release
this.get('store').query('github-release', { repo: 'jimmay5469/old-hash' }) // get a repo's releases
```
## Contributing

@@ -54,2 +103,2 @@

For more information on using ember-cli, visit [http://ember-cli.com/](http://ember-cli.com/).
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc