Skip to content

Commit

Permalink
fix: getInstallationAccesToken() → getInstallationAccessToken() (#12)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `app.getInstallationAccesToken()` had a typo and was renamed to `app.getInstallationAccessToken()`
  • Loading branch information
chrisrowe authored and gr2m committed Dec 12, 2018
1 parent 9889587 commit 3e7e2de
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const APP_ID = 1 // replace with your app ID
const PRIVATE_KEY = '-----BEGIN RSA PRIVATE KEY-----\n...' // replace with contents of your private key. Replace line breaks with \n

const app = new App({ id: APP_ID, privateKey: PRIVATE_KEY })
const installationAccessToken = await app.getInstallationAccesToken({ installationId })
const installationAccessToken = await app.getInstallationAccessToken({ installationId })

// https://developer.github.com/v3/issues/#create-an-issue
await request('POST /repos/:owner/:repo/issues', {
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = App

const getCache = require('./lib/get-cache')
const getInstallationAccesToken = require('./lib/get-installation-access-token')
const getInstallationAccessToken = require('./lib/get-installation-access-token')
const getSignedJsonWebToken = require('./lib/get-signed-json-web-token')

function App ({ id, privateKey, cache }) {
Expand All @@ -12,7 +12,7 @@ function App ({ id, privateKey, cache }) {
}
const api = {
getSignedJsonWebToken: getSignedJsonWebToken.bind(null, state),
getInstallationAccesToken: getInstallationAccesToken.bind(null, state)
getInstallationAccessToken: getInstallationAccessToken.bind(null, state)
}

return api
Expand Down
4 changes: 2 additions & 2 deletions lib/get-installation-access-token.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module.exports = getInstallationAccesToken
module.exports = getInstallationAccessToken

const request = require('@octokit/request')

const getSignedJsonWebToken = require('./get-signed-json-web-token')

// https://developer.github.com/v3/apps/#create-a-new-installation-token
function getInstallationAccesToken (state, { installationId }) {
function getInstallationAccessToken (state, { installationId }) {
const token = state.cache.get(installationId)
if (token) {
return Promise.resolve(token)
Expand Down
16 changes: 8 additions & 8 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('app.js', () => {
token: 'foo'
})

return app.getInstallationAccesToken({ installationId: 123 })
return app.getInstallationAccessToken({ installationId: 123 })
.then(token => {
expect(token).to.equal('foo')
})
Expand All @@ -83,11 +83,11 @@ describe('app.js', () => {
token: 'foo'
})

return app.getInstallationAccesToken({ installationId: 123 })
return app.getInstallationAccessToken({ installationId: 123 })
.then(token => {
expect(token).to.equal('foo')

return app.getInstallationAccesToken({ installationId: 123 })
return app.getInstallationAccessToken({ installationId: 123 })
})
.then(token => {
expect(token).to.equal('foo')
Expand All @@ -105,11 +105,11 @@ describe('app.js', () => {
token: 'bar'
})

return app.getInstallationAccesToken({ installationId: 123 })
return app.getInstallationAccessToken({ installationId: 123 })
.then(token => {
expect(token).to.equal('foo')

return app.getInstallationAccesToken({ installationId: 456 })
return app.getInstallationAccessToken({ installationId: 456 })
})
.then(token => {
expect(token).to.equal('bar')
Expand All @@ -128,7 +128,7 @@ describe('app.js', () => {
token: 'bar'
})

return app.getInstallationAccesToken({ installationId: 123 })
return app.getInstallationAccessToken({ installationId: 123 })
.then(token => {
expect(token).to.equal('foo')

Expand All @@ -138,7 +138,7 @@ describe('app.js', () => {
})
})
.then(() => {
return app.getInstallationAccesToken({ installationId: 123 })
return app.getInstallationAccessToken({ installationId: 123 })
})
.then(token => {
expect(token).to.equal('bar')
Expand All @@ -163,7 +163,7 @@ describe('app.js', () => {
}
const appWithCustomCache = new App(options)

return appWithCustomCache.getInstallationAccesToken({ installationId: 123 })
return appWithCustomCache.getInstallationAccessToken({ installationId: 123 })
.then(token => {
expect(options.cache.get.callCount).to.equal(1)
expect(options.cache.set.callCount).to.equal(1)
Expand Down

0 comments on commit 3e7e2de

Please sign in to comment.