Wired /bch REST API to BCH use-case lib

This commit is contained in:
Chris Troutner
2021-11-26 07:23:00 -08:00
parent 43759b7a3e
commit e73afdcd6c
3 changed files with 45 additions and 3 deletions
+4 -3
View File
@@ -42,9 +42,10 @@ class BchRESTControllerLib {
async getStatus (ctx) {
try {
// const users = await _this.useCases.user.getAllUsers()
const status = {
test: 'test'
}
// const status = {
// test: 'test'
// }
const status = await this.useCases.bch.getStatus()
ctx.body = { status }
} catch (err) {
+39
View File
@@ -0,0 +1,39 @@
/*
This library contains business-logic for dealing with BCH wallet service
providers. Most of these functions are called by the /bch REST API endpoints.
*/
// const UserEntity = require('../entities/user')
const { wlogger } = require('../adapters/wlogger')
class BchUseCases {
constructor (localConfig = {}) {
// console.log('User localConfig: ', localConfig)
this.adapters = localConfig.adapters
if (!this.adapters) {
throw new Error(
'Instance of adapters must be passed in when instantiating User Use Cases library.'
)
}
// Encapsulate dependencies
// this.UserEntity = new UserEntity()
// this.UserModel = this.adapters.localdb.Users
}
async getStatus () {
try {
const status = {
test: 'test'
}
return status
} catch (err) {
// console.log('createUser() error: ', err)
wlogger.error('Error in use-cases/bch.js/getStatus()')
throw err
}
}
}
module.exports = BchUseCases
+2
View File
@@ -5,6 +5,7 @@
*/
const UserUseCases = require('./user')
const BchUseCases = require('./bch')
class UseCases {
constructor (localConfig = {}) {
@@ -17,6 +18,7 @@ class UseCases {
// console.log('use-cases/index.js localConfig: ', localConfig)
this.user = new UserUseCases(localConfig)
this.bch = new BchUseCases(localConfig)
}
}