Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Sharafian committed Mar 16, 2018
1 parent f34c125 commit c0934b0
Show file tree
Hide file tree
Showing 5 changed files with 1,540 additions and 10 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends: standard
4 changes: 2 additions & 2 deletions client.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ function u8tohex (arr) {
return ret
}

window.addEventListener('load', function (receiver) {
window.addEventListener('load', function (receiverUrl) {
var idBytes = new Uint8Array(16)
crypto.getRandomValues(idBytes)
var id = u8tohex(idBytes)
var receiver = receiver.replace(/:id/, id)
var receiver = receiverUrl.replace(/:id/, id)

if (window.monetize) {
window.monetize({
Expand Down
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class KoaWebMonetization {
await this.plugin.connect()

this.receiver = await createReceiver({
plugin,
plugin: this.plugin,
paymentHandler: async params => {
const amount = params.prepare.amount
const id = params.prepare.destination.split('.').slice(-3)[0]
Expand Down Expand Up @@ -53,9 +53,9 @@ class KoaWebMonetization {

if (balance < price) {
throw new Error('insufficient balance on id.' +
' id=' + id,
' price=' + price,
' balance=' + balance)
' id=' + id,
' price=' + price,
' balance=' + balance)
}

this.buckets.set(id, balance - price)
Expand All @@ -65,7 +65,7 @@ class KoaWebMonetization {
return async ctx => {
const id = ctx.params.id
if (!id) {
return ctx.throw(400, 'ctx.params.id must be defined')
return ctx.throw(400, 'ctx.params.id must be defined')
}

const _price = (typeof price === 'function')
Expand All @@ -77,7 +77,7 @@ class KoaWebMonetization {
}

try {
spend(id, _price)
this.spend(id, _price)
} catch (e) {
return ctx.throw(402, e.message)
}
Expand Down Expand Up @@ -108,3 +108,5 @@ class KoaWebMonetization {
}
}
}

module.exports = KoaWebMonetization
Loading

0 comments on commit c0934b0

Please sign in to comment.