Customizing for bch

This commit is contained in:
Chris Troutner
2022-03-01 18:36:15 -08:00
parent 649655c7bb
commit d1fb676a8f
5 changed files with 24 additions and 2 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ const ipfsCoordName = process.env.COORD_NAME
module.exports = {
// Configure TCP port.
port: process.env.PORT || 5002,
port: process.env.PORT || 5700,
// Password for HTML UI that displays logs.
logPass: 'test',
@@ -49,6 +49,18 @@ class OrderRESTControllerLib {
}
}
// curl -X GET http://localhost:5700/order/list
async listOrders (ctx) {
try {
const orders = await _this.useCases.order.listOrders()
ctx.body = orders
} catch (err) {
console.log('Error in listOrders REST API handler.')
_this.handleError(ctx, err)
}
}
// DRY error handler
handleError (ctx, err) {
console.log('err', err.message)
+1
View File
@@ -50,6 +50,7 @@ class OrderRouter {
// Define the routes and attach the controller.
this.router.post('/', _this.orderRESTController.createOrder)
this.router.get('/list', _this.orderRESTController.listOrders)
// Attach the Controller routes to the Koa app.
app.use(_this.router.routes())
+9
View File
@@ -56,6 +56,15 @@ class OrderUseCases {
throw err
}
}
async listOrders () {
try {
return this.OrderModel.find({})
} catch (error) {
console.error('Error in use-cases/order/listOrders()')
throw error
}
}
}
module.exports = OrderUseCases
+1 -1
View File
@@ -6,7 +6,7 @@
const axios = require('axios')
const LOCALHOST = 'http://localhost:5002'
const LOCALHOST = 'http://localhost:5700'
async function start () {
try {