Socket
Socket
Sign inDemoInstall

ember-git-data

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-git-data

The default blueprint for ember-cli addons.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Ember Git Data

Minimal wrapper for git-data.js. For API info, please see git-data.js's docs.

Install

$ ember install ember-git-data

Use

Extend the Ember.Service that comes with this addon, and provide your GitHub access token:

// app/services/github.js
import Ember from 'ember'
import GitHub from 'ember-git-data/services/github'

const {
  inject: { service },
  computed: { readOnly },
} = Ember

// don't forget to extend!
export default GitHub.extend({
  session: service(),
  token: readOnly('session.accessToken'),
})

You can now create as many Repo objects as you wish. Often, you will want to return the Repo object as part of an Ember.Route's model hook:

// app/routes/index.js
import Ember from 'ember'

const {
  inject: { service },
  get,
} = Ember

export default Ember.Route.extend({
  github: service(),

  async model() {
    const g = get(this, 'github')
    const repo = g.repo({
      owner: 'nucleartide',
      repo: 'ember-git-data',
      branch: 'master',
    })

    try {
      const packageJson = await repo.readFile('package.json')
      return { packageJson, repo }
    } catch (err) {
      // ...
    }
  },

  actions: {
    doStuffWithRepo() {
      const { repo } = this.modelFor(this.routeName)
      // ...
    }
  }
})

The Repo object is now cached while a user is visiting the route, and you can perform any actions you wish.

Async/Await Note

The async/await syntax works with apps that opt in by setting the following in their ember-cli-build.js:

babel: {
  includePolyfill: true
}

Rationale

Why not use Ember Data?

Ember Data is great, and git-data.js could have easily been implemented as Ember Data models/adapters/serializers. I wanted to decouple git-data.js from Ember Data though, and make it usable in non-Ember environments.

Why not extend ember-data-github?

git-data.js focuses solely on GitHub's Git Data API. ember-data-github seems to have a broader focus.

Keywords

FAQs

Package last updated on 16 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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