StrapIO the ez to use socket.io configurator

Hey,

I wrote a little module to use socket.io without pain. It verifies the token and used role permissions to decide when to emit events to user. You can install it via npm.

npm i strapio

6 Likes

Hi @larsonnn, pardon my noob question, but is this module for creating notifications within Strapi?

Hello i install this module but i don’t find the file on api, maybe strapi developments delete?? greetings

strapio will emit some socketio messages. So when you mean by notifications that its sending socketio messages, yes.

Which file? StrapIO will be in your node_modules. You need to write some code yourself.

@larsonnn I’m wondering if building a middleware to emit the socket.io events might be better (maybe with a whitelist, could be cool to create a plugin or something for this :thinking:)

the problem with middleware is the lack of information. AFAIK, you have not all information in middleware for validating if someone has the permission to receive the message etc. Its missing for example the controller information.

middleware has only context information. So far you would need to inject the needed information in custom controllers.

But maybe someone knows more.

I was playing around and just built a plugin for it lol: strapi-plugin-socket - npm

This is just a sample and I won’t likely maintain it.

1 Like

It would be nice if someone could maintain it.

Thanks for this great source.

1 Like

Happy to hand the package and repo over to anyone who wants to maintain it, I only did it as a test honestly and there is a lot of extra features that could be added.

1 Like