My Hapi route calls my handler handler: myController.get
which is defined as
const myController = new MyController();
and MyController just extends BaseController as we see below
export class MyController extends BaseController<MyClass> {
constructor () {
super(new MyDataAccess());
}
}
with BaseController being
export class BaseController<T> {
constructor(protected dataAccess: BaseDataAccess<T>) { }
public async getAll(request, reply) {
console.log('BaseController this', this);
Oddly enough, this
prints out as 'undefined', which doesn't make any sense because I have already instantiated myController in the route file, which should've kicked off a new instance of BaseController for this
to invoke, right?
Question How can I access an instance of MyController from a Hapi route handler?