Saturday 17 November 2018

Inmemory-like database in Nest

I've started learning Nest recently and I've come up with a simple game based on websockets and there's a problem that I have to face now.There is A service that handles every fetch API requests with room creation etc. and then there is websocket gateway that handles the room on anything that requires data-sharing between players.So I need to access the same data structure that I've implemented for Room and that is an array. I'm not using any database.What I did was create state folder with state.module and state.service that handles everything that can be done with the room so like - creation, updating, new player etc. This state.service is then exported and imported in socket.module and room.module and injected (using Inject) into socket.gateway and room.service. This way I can access every method I've created in state and manage it accordingly. I was kinda okay with this but while rereading docs and hearing my colleague saying that it is not quite it and I'm not sure what should I do.Is it okay to leave it as it is or should I change it?

Submitted November 17, 2018 at 02:12PM by Azztyn

No comments:

Post a Comment