mirror of
https://github.com/Permissionless-Software-Foundation/psf-memo-db.git
synced 2026-09-21 16:52:02 -07:00
34 lines
909 B
JavaScript
34 lines
909 B
JavaScript
/*
|
|
REST API router for /profile routes.
|
|
*/
|
|
|
|
import Router from 'koa-router'
|
|
import ProfileRESTControllerLib from './controller.js'
|
|
|
|
class ProfileRouter {
|
|
constructor (localConfig = {}) {
|
|
this.adapters = localConfig.adapters
|
|
this.useCases = localConfig.useCases
|
|
if (!this.adapters) {
|
|
throw new Error('Adapters required when instantiating Profile REST Controller.')
|
|
}
|
|
if (!this.useCases) {
|
|
throw new Error('Use Cases required when instantiating Profile REST Controller.')
|
|
}
|
|
|
|
this.profileRESTController = new ProfileRESTControllerLib({
|
|
adapters: this.adapters,
|
|
useCases: this.useCases
|
|
})
|
|
this.router = new Router({ prefix: '/profile' })
|
|
}
|
|
|
|
attach (app) {
|
|
this.router.get('/recent', this.profileRESTController.getRecentProfiles)
|
|
app.use(this.router.routes())
|
|
app.use(this.router.allowedMethods())
|
|
}
|
|
}
|
|
|
|
export default ProfileRouter
|