HoukasaurusRex / boilerplate-express-ts-server

A Best Practices™️ Express.js and Typescript server with clustering and socket.io
https://perfect-express-ts-server.herokuapp.com/
MIT License
4 stars 1 forks source link

Providers file structure #5

Open TNieminen opened 4 years ago

TNieminen commented 4 years ago

In addition to issue #4 there will be cases where we want to do file splitting under one scope. Let's for instance presume that we have multiple functionalities under socket.ts which we want to split into multiple files, with the proposed file structure it would maybe look something like this (if I am not mistaken):

providers
  |
  errors.ts 
  index.ts 
  sockets.ts 
  sockets.split-func.ts
  sockets.another-split-func.ts
  users.ts

and this would get quite verbose quite quickly. As a proposition to this what about scoping under files like so:

providers
  |
  errors
     |
     index.ts
     test.ts
  socket
     |
     index.ts
     split-func.ts
     another-split-func.ts
     test.ts
  users
     |
     index.ts
     test.ts
TNieminen commented 4 years ago

@HoukasaurusRex I think we discussed earlier that it's not likely for providers normally grow to be that large. I think you proposed taking sockets outside of the providers, which I actually kind of like because in the future I can see us separating that socket logic into a separate service or potentially removing it entirely. And event if it was to stay it doesn't feel unnatural. For instance sockets have different real-time requirements for global change turn functionality which might need more flexibility than the current EB deployment.

HoukasaurusRex commented 4 years ago

Right, and that would make sense if we don't include test files in the providers folder as well.