-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
2,309 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
{ | ||
"@context": "https://w3id.org/payswarm/v1", | ||
"id": "http: //listings.dev.payswarm.com/mozhacks/demo#asset", | ||
"id": "http://listings.dev.payswarm.com/mozhacks/demo#asset", | ||
"userId": "~", | ||
"type": [ | ||
"Asset" | ||
], | ||
"creator": { | ||
"fullName": "DeveloperJoe" | ||
}, | ||
"title": "MozillaHacksDemoAsset", | ||
"assetContent": "http: //listings.dev.payswarm.com/mozhacks/demo#asset", | ||
"assetProvider": "https: //dev.payswarm.com/i/YOUR_IDENTITY_HERE" | ||
"assetContent": "http://listings.dev.payswarm.com/mozhacks/demo#asset", | ||
"assetProvider": "https://dev.payswarm.com/i/YOUR_IDENTITY_HERE" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
var mongoose = require('mongoose'); | ||
var _ = require('underscore'); | ||
|
||
if (process.env.NODE_ENV) | ||
var db = mongoose.connect('mongodb://nodejitsu:[email protected]:10074/nodejitsudb4747069906'); | ||
else | ||
var db = mongoose.connect('mongodb://localhost:27017/webpayments'); | ||
else { | ||
console.log('localhost'); | ||
var db = mongoose.connect('mongodb://localhost:27017/webpay'); | ||
} | ||
|
||
var schemas = require('./schemas')(db); | ||
|
||
function assert() { | ||
argv = _.toArray(arguments); | ||
if(!argv[0]) { | ||
console.log(argv[2]); | ||
throw new Error('Expected ' + argv[1] + ' to be defined'); | ||
} | ||
} | ||
|
||
var dbUtils = { | ||
find: function (schema, query, fields, cb) { | ||
if (typeof fields === 'function') { | ||
|
@@ -26,21 +37,28 @@ var dbUtils = { | |
} | ||
}, | ||
save : { | ||
asset : function (graph, cb) { | ||
var listing = new schemas.Listing(graph.listing); | ||
console.log(graph.asset); | ||
var asset = new schemas.Asset(graph.asset); | ||
asset: function (assetAndListing, cb) { | ||
|
||
console.log(arguments); | ||
|
||
asset.save(function (err, d) { | ||
if (err) cb(err); | ||
else { | ||
listing.assetId = d['_id']; | ||
var asset = new schemas.Asset(assetAndListing['@graph'][0]); | ||
var listing = new schemas.Listing(assetAndListing['@graph'][1]); | ||
|
||
asset.save(function (err) { | ||
console.log('asset err', err); | ||
if (err) { | ||
cb(err); | ||
} else { | ||
listing.save(function (err) { | ||
if (err) cb(err); | ||
else cb(null); | ||
console.log('listing err', err); | ||
if (err) { | ||
cb(err); | ||
} else { | ||
cb(null); | ||
} | ||
}) | ||
} | ||
}); | ||
}) | ||
} | ||
}, | ||
findOne: { | ||
|
@@ -67,21 +85,14 @@ var dbUtils = { | |
user: function (fields, user, cb) { | ||
schemas.User.findOne(user, fields, dbUtils.next(cb)); | ||
}, | ||
asset: function (query, cb) { | ||
schemas.Asset.find(query, dbUtils.next(cb)); | ||
}, | ||
listing: function (query, cb) { | ||
schemas.Listing.find(query, dbUtils.next(cb)); | ||
}, | ||
userAssets: function (query, cb) { | ||
dbUtils.get.user({ | ||
owner: 1 | ||
}, query, function (err, doc) { | ||
if (err) { | ||
console.log(err); | ||
cb(err); | ||
} else { | ||
console.log(doc); | ||
console.log(query); | ||
schemas.Asset.find({ | ||
assetProvider: doc.owner | ||
}, dbUtils.next(cb)); | ||
} | ||
}) | ||
schemas.Asset.find(query, dbUtils.next(cb)); | ||
}, | ||
userListings: function (id, cb) { | ||
dbUtils.find(schemas.Listing, {assetId: id}, dbUtils.next(cb)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"@context": "https://w3id.org/payswarm/v1", | ||
"id": "http://listings.dev.payswarm.com/mozhacks/html5-me-song#listing", | ||
"userId": "~", | ||
"type": ["Listing"], | ||
"vendor": "https://dev.payswarm.com/i/the-webdevs", | ||
"payee": [{ | ||
"type": "Payee", | ||
"destination": "https://dev.payswarm.com/i/the-webdevs/accounts/royalties", | ||
"payeeGroup": ["vendor"], | ||
"payeeRateType": "FlatAmount", | ||
"payeeRate": "1.00", | ||
"currency": "USD", | ||
"payeeApplyType": "ApplyExclusively", | ||
"comment": "Payment to The Webdevs for creating the HTML5 Me, Baby song" | ||
}], | ||
"payeeRule": [{ | ||
"type": "PayeeRule", | ||
"payeeGroupPrefix": ["authority"], | ||
"payeeRateType": "Percentage", | ||
"maximumPayeeRate": "5", | ||
"payeeApplyType": "ApplyInclusively" | ||
}], | ||
"asset": "http://listings.dev.payswarm.com/mozhacks/html5-me-song#asset", | ||
"assetHash": "assetHash", | ||
"license": "https://w3id.org/payswarm/licenses/personal-use", | ||
"licenseHash": "urn:sha256:d9dcfb7b3ba057df52b99f777747e8fe0fc598a3bb364e3d3eb529f90d58e1b9", | ||
"validFrom": "date", | ||
"validUntil": "date" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Public Key Owner : https://dev.payswarm.com/i/piatra | ||
Financial Account: https://dev.payswarm.com/i/piatra/accounts/primary | ||
Public Key URL : https://dev.payswarm.com/i/piatra/keys/30 |
Oops, something went wrong.