Code files

This commit is contained in:
Akhil
2017-07-31 11:33:31 +05:30
parent 073a63ebdd
commit b9ae409ec0
801 changed files with 17535 additions and 0 deletions
@@ -0,0 +1,34 @@
'use strict'
const { Router } = require('express')
const restify = require('restify')
const router = Router()
const {
ADDERSERVICE_SERVICE_HOST,
ADDERSERVICE_SERVICE_PORT
} = process.env
router.get('/', function (req, res) {
res.render('add', { first: 0, second: 0, result: 0 })
})
router.post('/calculate', function (req, res, next) {
const client = restify.createJSONClient({
url: `http://${ADDERSERVICE_SERVICE_HOST}:${ADDERSERVICE_SERVICE_PORT}`
})
const { first, second } = req.body
client.get(
`/add/${first}/${second}`,
(err, svcReq, svcRes, data) => {
if (err) {
next(err)
return
}
const { result } = data
res.render('add', { first, second, result })
}
)
})
module.exports = router