mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-23 01:22:03 -07:00
linting
This commit is contained in:
@@ -7,7 +7,6 @@ const Router = require('koa-router')
|
||||
|
||||
// Local libraries.
|
||||
const ContactRESTControllerLib = require('./controller')
|
||||
const Validators = require('../middleware/validators')
|
||||
|
||||
class ContactRouter {
|
||||
constructor (localConfig = {}) {
|
||||
@@ -32,7 +31,6 @@ class ContactRouter {
|
||||
|
||||
// Encapsulate dependencies.
|
||||
this.contactRESTController = new ContactRESTControllerLib(dependencies)
|
||||
this.validators = new Validators()
|
||||
|
||||
// Instantiate the router and set the base route.
|
||||
const baseUrl = '/contact'
|
||||
|
||||
@@ -2,16 +2,54 @@
|
||||
REST API library for /logs route.
|
||||
*/
|
||||
|
||||
const LogsRESTRouter = require('./router')
|
||||
// Public npm libraries.
|
||||
const Router = require('koa-router')
|
||||
|
||||
class LogsRESTController {
|
||||
// Local libraries.
|
||||
const LogsRESTControllerLib = require('./controller')
|
||||
|
||||
class LogsRouter {
|
||||
constructor (localConfig = {}) {
|
||||
this.logsRESTRouter = new LogsRESTRouter()
|
||||
// Dependency Injection.
|
||||
this.adapters = localConfig.adapters
|
||||
if (!this.adapters) {
|
||||
throw new Error(
|
||||
'Instance of Adapters library required when instantiating Logs REST Controller.'
|
||||
)
|
||||
}
|
||||
this.useCases = localConfig.useCases
|
||||
if (!this.useCases) {
|
||||
throw new Error(
|
||||
'Instance of Use Cases library required when instantiating Logs REST Controller.'
|
||||
)
|
||||
}
|
||||
|
||||
const dependencies = {
|
||||
adapters: this.adapters,
|
||||
useCases: this.useCases
|
||||
}
|
||||
|
||||
this.logsRESTController = new LogsRESTControllerLib(dependencies)
|
||||
|
||||
// Instantiate the router and set the base route.
|
||||
const baseUrl = '/logs'
|
||||
this.router = new Router({ prefix: baseUrl })
|
||||
}
|
||||
|
||||
attach (app) {
|
||||
this.logsRESTRouter.attachControllers(app)
|
||||
if (!app) {
|
||||
throw new Error(
|
||||
'Must pass app object when attaching REST API controllers.'
|
||||
)
|
||||
}
|
||||
|
||||
// Define the routes and attach the controller.
|
||||
this.router.post('/', this.logsRESTController.getLogs)
|
||||
|
||||
// Attach the Controller routes to the Koa app.
|
||||
app.use(this.router.routes())
|
||||
app.use(this.router.allowedMethods())
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = LogsRESTController
|
||||
module.exports = LogsRouter
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
REST Router for the /logs route.
|
||||
*/
|
||||
|
||||
// Public npm libraries.
|
||||
const Router = require('koa-router')
|
||||
|
||||
// Local libraries.
|
||||
const LogsRESTControllerLib = require('./controller')
|
||||
const Validators = require('../middleware/validators')
|
||||
|
||||
// let _this
|
||||
|
||||
class LogsRESTRouter {
|
||||
constructor (localConfig = {}) {
|
||||
// Encapsulate dependencies.
|
||||
this.logsRESTController = new LogsRESTControllerLib()
|
||||
this.validators = new Validators()
|
||||
|
||||
// Instantiate the router and set the base route.
|
||||
const baseUrl = '/logs'
|
||||
this.router = new Router({ prefix: baseUrl })
|
||||
|
||||
// _this = this
|
||||
}
|
||||
|
||||
attachControllers (app) {
|
||||
if (!app) {
|
||||
throw new Error(
|
||||
'Must pass app object when attaching REST API controllers.'
|
||||
)
|
||||
}
|
||||
|
||||
// Define the routes and attach the controller.
|
||||
this.router.post('/', this.logsRESTController.getLogs)
|
||||
|
||||
// Attach the Controller routes to the Koa app.
|
||||
app.use(this.router.routes())
|
||||
app.use(this.router.allowedMethods())
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = LogsRESTRouter
|
||||
Reference in New Issue
Block a user