UltraRangers / gauntlet

Gauntlet is a Typescript server template to kick-off your development fast 🔥🔥🔥
https://gauntlet-demo.herokuapp.com
MIT License
3 stars 0 forks source link

File structure #4 #5

Closed ghost closed 6 years ago

ghost commented 6 years ago

@jmaicaaan @dach020 @john20xdoe Pull request for #4, do guys think we need to restructure this when some things on the future comes up like a common folder?

ghost commented 6 years ago

Putting the client and server in src folder is ok for me, just considering some future conflicts. Note: One thing to have here on mind are the configurations, more likely the client and server should have different tsconfig.json because they don't have the same compiling style.

john20xdoe commented 6 years ago

I also think they should be separated, though mostly considering whether they will be deployed separately (covering their difference in the config). IF they are deployed together in one instance their difference in config will still require a central config in the root dir.

jmaicaaan commented 6 years ago

Putting it to the src folder is fine and also having different configs. Having a common config will need to be add in the root dir as @john20xdoe said. In the case of common folder which is available for client and server. I believe we will not have any problems with that knowing that everything insider the src would be compiled and added into dist folder as is. Hence, they will still get the folder reference into it. Also, when they've compiled, it will be using some file-loader to resolve paths rights?

src dist
client client
common common
server server
ghost commented 6 years ago

@john20xdoe That is the first plan and I also agree on that structure. Though @jmaicaaan and I have some discussion about using one src folder. @jmaicaaan about the compiled folders, I don't think the dist will have a common folder. Do you mean that common folder has a tsconfig.json also? For the common folder to be compiled? I am absolutely sure that the client and server has different compiling style.

jmaicaaan commented 6 years ago

I do have a suggestion for the problem regarding the common folder. My suggestion is to have a base config for the project and have those separated tsconfig.json extends the base tsconfig. (See attached)

a

Another one, I believe the config in the server and client contains .json files. With that, how can we load those things up? For example, in the server we require the abc.json which is in the server/config folder into the app. How do we resolve it? My suggestion is to make it simple and move those config files to the root and have a client and server up there. With that, config files are now free from unresolved paths.

${project_root}/config/client - All configs for client ${project_root}/config/server - All configs for server

Thoughts?

john20xdoe commented 6 years ago

^ this is actually good. Pros: centralized config. Cons: Though it will cause a (slight) issue if server and client are being deployed separately. I say "slightly" because such issues (e.g., bundling the correct config for the deployment folder) can be worked around as needed.

As another important concern, in cases of configs (especially if there are secrets such as passwords) we may need to rethink an approach. https://softwareengineering.stackexchange.com/questions/205606/strategy-for-keeping-secret-info-such-as-api-keys-out-of-source-control

john20xdoe commented 6 years ago

Related literature: https://github.com/lorenwest/node-config/wiki

ghost commented 6 years ago

@jmaicaaan @john20xdoe thanks for this. Moving configuration folder in root directory is good. Let me research more about simplifying our compilation, because we are having many tsconfiguration. I will be labelling this a high priority because this will be the foundation. I will get back to you guys for the report.

jmaicaaan commented 6 years ago

In the case of secret passwords or any important keys. What we can do there is using the environment variables approach and never ever store it in the app. With that, it is away from the source code and I believe considered as best practice for deployment. (eg: .env files)

The issue that may occur if the client and server will be deployed separately is an anti-pattern to our folder structure since we bundled them into one src folder. If we are going to deploy them separately, I believe we should not put them into one folder under src and have a client and server folder in the root.

@cedrickmandocdoc, let's get it done!

ghost commented 6 years ago

@jmaicaaan PR updated, I extend the tsconfig in root. I conclude that your suggestion is probably good. Using extendable typescript configuration is probably like what the angular did on their structure.Using this approach, it is easy to scale app with different environment. Anyways we are using webpack v4 and it is compiling and bundling has somehow change so it throws some warnings, I will create another issue for that. So overall after this PR merged. All tickets can now be developed.

jmaicaaan commented 6 years ago

Hi @cedrickmandocdoc , can you check my changes if that's okay? The things I've made are:

Let me here your thoughts! If everything is good, I shall merge this branch up into master then

ghost commented 6 years ago

@jmaicaaan this is good to go. Thank you. By the way the CI is failing because of some peer dependencies can we ignore this for now or it should be fixed?

ghost commented 6 years ago

I think it is because of some packages we've used in loaders for webpack. I can't just pinpoint it.

jmaicaaan commented 6 years ago

@cedrickmandocdoc, no we don't need to fix it on this branch. Let's create another ticket on that issue.. Looks like we need to let the CI know our node version for the peer deps.