Where to place adonis-pusher in my adonis application

#1

Hello,

I need to place the adonis-pusher in my adonis application.

I see a good place is to place within a controller, but I would need to do something like placing into the server.js.

Basically I need to use this pusher along with a watch() on a mongo-db collection:

const taskCollection = db.collection('tasks');
const changeStream = taskCollection.watch();
changeStream.on('change', (change) => {
        console.log(change);
});

I would place this code within the server.js file but I am not sure it is appropriate despite that it can be done.

What do you suggest?

0 Likes

#2

Hello,

I’ve put this listener in a Service providere in the end.
I see it works as expected, and the code runs into the boot() method.

0 Likes