I want to create a Class and make it available on my controllers. I don't want to use helpers in this particular case because I'm planning to create an npm package later with this code. I don't want to create a package now, because I don't want my code to be public.
I've tried adding this code inside a file in the hooks folder:
console.log('Hook executed!');
module.exports = class Test {
constructor() {
console.log('Object created!');
}
}
Then in a random controller:
const test = new Test();
The hook it's being loaded but then I'm getting:
ReferenceError: Test is not defined
from Create a Class to be used on controllers
No comments:
Post a Comment