Skip to content

Commit

Permalink
Merge cdc256a into 818aced
Browse files Browse the repository at this point in the history
  • Loading branch information
Agupane committed Jul 18, 2019
2 parents 818aced + cdc256a commit dd03a4f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
14 changes: 13 additions & 1 deletion server/delegator/delegator.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ const getNextReward = async (req, res, next) => {
}
}

const getDelegator = async (req, res, next) => {
const { address } = req.params
try {
const delegatorService = getDelegatorService()
const delegator = await delegatorService.getDelegatorAccount(address)
res.json({ delegator })
} catch (error) {
next(error)
}
}

module.exports = {
getNextReward
getNextReward,
getDelegator
}
7 changes: 6 additions & 1 deletion server/delegator/delegator.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ const validate = require('express-validation')
const paramValidation = require('../../config/param-validation')

const router = express.Router() // eslint-disable-line new-cap
const { getNextReward } = require('./delegator.controller')
const { getNextReward, getDelegator } = require('./delegator.controller')

/** GET /api/delegators/reward/:address - Get delegate next reward by address */
router
.route('/reward/:address')

.get(validate(paramValidation.getByAddress), getNextReward)

router
.route('/address/:address')

.get(validate(paramValidation.getByAddress), getDelegator)

module.exports = router
35 changes: 34 additions & 1 deletion utils/livepeer-alerts-backend.postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info": {
"_postman_id": "57a8f6cc-574a-4168-9238-50fc0ba10bb6",
"_postman_id": "fd460187-e73f-4bb0-a0d5-3a0500c0e2fd",
"name": "livepeer-alerts-backend",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
Expand Down Expand Up @@ -502,6 +502,39 @@
}
},
"response": []
},
{
"name": "[GET] - /api/delegators/address/:address",
"request": {
"method": "GET",
"header": [
{
"key": "Referer",
"value": "http://localhost:3000",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://localhost:4040/api/delegators/address/0x155cCf41305F5fE3FAae64eCea8a1E2cAd08F085",
"protocol": "http",
"host": [
"localhost"
],
"port": "4040",
"path": [
"api",
"delegators",
"address",
"0x155cCf41305F5fE3FAae64eCea8a1E2cAd08F085"
]
},
"description": "Gets information about a delegator"
},
"response": []
}
]
}

0 comments on commit dd03a4f

Please sign in to comment.