From e73afdcd6c210d7774a1efcce765953df40e25ed Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Fri, 26 Nov 2021 07:23:00 -0800 Subject: [PATCH] Wired /bch REST API to BCH use-case lib --- src/controllers/rest-api/bch/controller.js | 7 ++-- src/use-cases/bch.js | 39 ++++++++++++++++++++++ src/use-cases/index.js | 2 ++ 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 src/use-cases/bch.js diff --git a/src/controllers/rest-api/bch/controller.js b/src/controllers/rest-api/bch/controller.js index 772ec2f..73382d6 100644 --- a/src/controllers/rest-api/bch/controller.js +++ b/src/controllers/rest-api/bch/controller.js @@ -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) { diff --git a/src/use-cases/bch.js b/src/use-cases/bch.js new file mode 100644 index 0000000..7ecfd83 --- /dev/null +++ b/src/use-cases/bch.js @@ -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 diff --git a/src/use-cases/index.js b/src/use-cases/index.js index 015368f..8dc5e0e 100644 --- a/src/use-cases/index.js +++ b/src/use-cases/index.js @@ -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) } }