-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
2fdfe48
commit 07eb8cb
Showing
54 changed files
with
4,444 additions
and
3,285 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
var Router = require('../../helpers/router'); | ||
var httpApi = require('../../helpers/httpApi'); | ||
var schema = require('../../schema/accounts.js'); | ||
|
||
// Constructor | ||
function AccountsHttpApi (accountsModule, app) { | ||
|
||
var router = new Router(); | ||
|
||
router.map(accountsModule.shared, { | ||
'post /open': 'open', | ||
'get /getBalance': 'getBalance', | ||
'get /getPublicKey': 'getPublickey', | ||
'post /generatePublicKey': 'generatePublicKey', | ||
'get /delegates': 'getDelegates', | ||
'get /delegates/fee': 'getDelegatesFee', | ||
'put /delegates': 'addDelegates', | ||
'get /': 'getAccount' | ||
}); | ||
|
||
router.map(accountsModule.internal, { | ||
'get /count': 'count' | ||
}); | ||
|
||
if (process.env.DEBUG && process.env.DEBUG.toUpperCase() === 'TRUE') { | ||
router.map(accountsModule.internal, {'get /getAllAccounts': 'getAllAccounts'}); | ||
} | ||
|
||
if (process.env.TOP && process.env.TOP.toUpperCase() === 'TRUE') { | ||
router.get('/top', httpApi.middleware.sanitize('query', schema.top, accountsModule.internal.top)); | ||
} | ||
|
||
httpApi.registerEndpoint('/api/accounts', app, router, accountsModule.isLoaded); | ||
} | ||
|
||
module.exports = AccountsHttpApi; |
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,29 @@ | ||
'use strict'; | ||
|
||
var Router = require('../../helpers/router'); | ||
var httpApi = require('../../helpers/httpApi'); | ||
|
||
// Constructor | ||
function BlocksHttpApi (blocksModule, app) { | ||
|
||
var router = new Router(); | ||
|
||
router.map(blocksModule.shared, { | ||
'get /get': 'getBlock', | ||
'get /': 'getBlocks', | ||
'get /getBroadhash': 'getBroadhash', | ||
'get /getEpoch': 'getEpoch', | ||
'get /getHeight': 'getHeight', | ||
'get /getNethash': 'getNethash', | ||
'get /getFee': 'getFee', | ||
'get /getFees': 'getFees', | ||
'get /getMilestone': 'getMilestone', | ||
'get /getReward': 'getReward', | ||
'get /getSupply': 'getSupply', | ||
'get /getStatus': 'getStatus' | ||
}); | ||
|
||
httpApi.registerEndpoint('/api/blocks', app, router, blocksModule.isLoaded); | ||
} | ||
|
||
module.exports = BlocksHttpApi; |
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,36 @@ | ||
'use strict'; | ||
|
||
var Router = require('../../helpers/router'); | ||
var httpApi = require('../../helpers/httpApi'); | ||
var schema = require('../../schema/dapps'); | ||
|
||
// Constructor | ||
function DappsHttpApi (dappsModule, app) { | ||
|
||
var router = new Router(); | ||
|
||
router.map(dappsModule.internal, { | ||
'get /categories': 'categories', | ||
'get /installed': 'installed', | ||
'get /installedIds': 'installedIds', | ||
'get /ismasterpasswordenabled': 'isMasterPasswordEnabled', | ||
'get /installing': 'installing', | ||
'get /uninstalling': 'uninstalling', | ||
'get /launched': 'launched', | ||
'post /launch': 'launch', | ||
'put /transaction': 'addTransactions', | ||
'put /withdrawal': 'sendWithdrawal' | ||
}); | ||
|
||
router.get('/', httpApi.middleware.sanitize('query', schema.list, dappsModule.internal.list)); | ||
router.put('/', httpApi.middleware.sanitize('body', schema.put, dappsModule.internal.put)); | ||
router.get('/get', httpApi.middleware.sanitize('query', schema.get, dappsModule.internal.get)); | ||
router.get('/search', httpApi.middleware.sanitize('query', schema.search, dappsModule.internal.search)); | ||
router.post('/install', httpApi.middleware.sanitize('body', schema.install, dappsModule.internal.install)); | ||
router.post('/uninstall', httpApi.middleware.sanitize('body', schema.uninstall, dappsModule.internal.uninstall)); | ||
router.post('/stop', httpApi.middleware.sanitize('body', schema.stop, dappsModule.internal.stop)); | ||
|
||
httpApi.registerEndpoint('/api/dapps', app, router, dappsModule.isLoaded); | ||
} | ||
|
||
module.exports = DappsHttpApi; |
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,39 @@ | ||
'use strict'; | ||
|
||
var Router = require('../../helpers/router'); | ||
var httpApi = require('../../helpers/httpApi'); | ||
|
||
// Constructor | ||
function DelegatesHttpApi (delegatesModule, app) { | ||
|
||
var router = new Router(); | ||
|
||
router.map(delegatesModule.shared, { | ||
'get /count': 'count', | ||
'get /search': 'search', | ||
'get /voters': 'getVoters', | ||
'get /get': 'getDelegate', | ||
'get /': 'getDelegates', | ||
'get /fee': 'getFee', | ||
'get /forging/getForgedByAccount': 'getForgedByAccount', | ||
'put /': 'addDelegate', | ||
'get /getNextForgers': 'getNextForgers' | ||
}); | ||
|
||
router.map(delegatesModule.internal, { | ||
'post /forging/enable': 'forgingEnable', | ||
'post /forging/disable': 'forgingDisable', | ||
'get /forging/status': 'forgingStatus' | ||
}); | ||
|
||
if (process.env.DEBUG) { | ||
router.map(delegatesModule.internal, { | ||
'get /forging/disableAll': 'forgingDisableAll', | ||
'get /forging/enableAll': 'forgingEnableAll' | ||
}); | ||
} | ||
|
||
httpApi.registerEndpoint('/api/delegates', app, router, delegatesModule.isLoaded); | ||
} | ||
|
||
module.exports = DelegatesHttpApi; |
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,24 @@ | ||
'use strict'; | ||
|
||
var Router = require('../../helpers/router'); | ||
var httpApi = require('../../helpers/httpApi'); | ||
|
||
// Constructor | ||
function LoaderHttpApi (loaderModule, app) { | ||
|
||
var router = new Router(); | ||
|
||
router.map(loaderModule.shared, { | ||
'get /status': 'status', | ||
'get /status/sync': 'sync' | ||
}); | ||
|
||
router.get('/status/ping', function (req, res) { | ||
var status = loaderModule.internal.statusPing(); | ||
return res.status(status ? 200 : 503).json({success: status}); | ||
}); | ||
|
||
httpApi.registerEndpoint('/api/loader', app, router, loaderModule.isLoaded); | ||
} | ||
|
||
module.exports = LoaderHttpApi; |
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,21 @@ | ||
'use strict'; | ||
|
||
var Router = require('../../helpers/router'); | ||
var httpApi = require('../../helpers/httpApi'); | ||
|
||
// Constructor | ||
function MultisignaturesHttpApi (mutlisignaturesModule, app) { | ||
|
||
var router = new Router(); | ||
|
||
router.map(mutlisignaturesModule.shared, { | ||
'get /pending': 'pending', | ||
'post /sign': 'sign', | ||
'put /': 'addMultisignature', | ||
'get /accounts': 'getAccounts' | ||
}); | ||
|
||
httpApi.registerEndpoint('/api/multisignatures', app, router, mutlisignaturesModule.isLoaded); | ||
} | ||
|
||
module.exports = MultisignaturesHttpApi; |
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,21 @@ | ||
'use strict'; | ||
|
||
var Router = require('../../helpers/router'); | ||
var httpApi = require('../../helpers/httpApi'); | ||
|
||
// Constructor | ||
function PeersHttpApi (peersModule, app) { | ||
|
||
var router = new Router(); | ||
|
||
router.map(peersModule.shared, { | ||
'get /': 'getPeers', | ||
'get /version': 'version', | ||
'get /get': 'getPeer', | ||
'get /count': 'count' | ||
}); | ||
|
||
httpApi.registerEndpoint('/api/peers', app, router, peersModule.isLoaded); | ||
} | ||
|
||
module.exports = PeersHttpApi; |
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,34 @@ | ||
'use strict'; | ||
|
||
var Router = require('../../helpers/router'); | ||
var httpApi = require('../../helpers/httpApi'); | ||
|
||
// Constructor | ||
function ServerHttpApi (serverModule, app) { | ||
|
||
var router = new Router(); | ||
|
||
router.use(function (req, res, next) { | ||
if (serverModule.areModulesReady()) { return next(); } | ||
res.status(500).send({success: false, error: 'Blockchain is loading'}); | ||
}); | ||
|
||
router.get('/', function (req, res) { | ||
if (serverModule.isLoaded()) { | ||
res.render('wallet.html', {layout: false}); | ||
} else { | ||
res.render('loading.html'); | ||
} | ||
}); | ||
|
||
router.use(function (req, res, next) { | ||
if (req.url.indexOf('/api/') === -1 && req.url.indexOf('/peer/') === -1) { | ||
return res.redirect('/'); | ||
} | ||
next(); | ||
}); | ||
|
||
app.use('/', router); | ||
} | ||
|
||
module.exports = ServerHttpApi; |
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,19 @@ | ||
'use strict'; | ||
|
||
var Router = require('../../helpers/router'); | ||
var httpApi = require('../../helpers/httpApi'); | ||
|
||
// Constructor | ||
function SignaturesHttpApi (signaturesModule, app) { | ||
|
||
var router = new Router(); | ||
|
||
router.map(signaturesModule.shared, { | ||
'get /fee': 'getFee', | ||
'put /': 'addSignature' | ||
}); | ||
|
||
httpApi.registerEndpoint('/api/signatures', app, router, signaturesModule.isLoaded); | ||
} | ||
|
||
module.exports = SignaturesHttpApi; |
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,27 @@ | ||
'use strict'; | ||
|
||
var Router = require('../../helpers/router'); | ||
var httpApi = require('../../helpers/httpApi'); | ||
|
||
// Constructor | ||
function TransactionsHttpApi (transactionsModule, app) { | ||
|
||
var router = new Router(); | ||
|
||
router.map(transactionsModule.shared, { | ||
'get /': 'getTransactions', | ||
'get /get': 'getTransaction', | ||
'get /count': 'getTransactionsCount', | ||
'get /queued/get': 'getQueuedTransaction', | ||
'get /queued': 'getQueuedTransactions', | ||
'get /multisignatures/get': 'getMultisignatureTransaction', | ||
'get /multisignatures': 'getMultisignatureTransactions', | ||
'get /unconfirmed/get': 'getUnconfirmedTransaction', | ||
'get /unconfirmed': 'getUnconfirmedTransactions', | ||
'put /': 'addTransactions' | ||
}); | ||
|
||
httpApi.registerEndpoint('/api/transactions', app, router, transactionsModule.isLoaded); | ||
} | ||
|
||
module.exports = TransactionsHttpApi; |
Oops, something went wrong.