Closed shizuko-akamoto closed 4 years ago
Wooo didn't know we can use yarn workspace to setup monorepo, that is pretty cool.
Can anyone connect to our db using these? We might need to hide these too haha
True. I will send it out in slack instead haha.
Closes #11
A lot of file change in this PR, due to a lot of files getting moved around. Though all the changes here except for setting up MongoDB connection from server and package.json changes, are generated using third party library so nothing to review there really.
Server-Client setup: We are going with monorepo setup instead of setting up a separate sever repo. Monorepo is built using yarn's workspace. In
package.json
at the project root, you will find this:Basically, we're telling it to treat each directory inside
packages
dir an individual package with its ownnode_module
. We currently have two packages:client
andserver
For server side, I used generator-express-no-stress-typescript. It's worth reading its README.
IMPORTANT (Maybe copy the commands out somewhere for later reference)
CHANGES TO INSTALLING FUTURE DEPENDENCIES
Now that we have 2 packages in this workspace, installing new dependencies need to use slightly different command.
To install dependency: On entire workspace:
yarn add package-name
On client side only:yarn workspace client add package-name
On server side only:yarn workspace server add package-name
HOW TO RUN THE PROJECT
I've configured concurrently to run multiple yarn scripts simultaneously, and nodemon to restart server on server side code change.
To run: Both server & client:
yarn start
Client only:yarn start:client
Server only:yarn start:server
CHANGES TO LINT ANT PRETTIER
Client and server code has separate eslint configuration, but prettier is configured generally by
.prettierrc.js
at the root. Also reinstalled husky and lint-staged at root node level, sogit commit
will run lint and prettier scripts as before. In case you want to run lint on other occasion, use below commands.To run lint: Both server & client:
yarn lint
Client code only:yarn lint:client
Server code only:yarn lint:server
.ENV FILE
Server code needs an .env file to run. Create a new file called
.env
inTrecipe > packages > server
directory and copy paste the following. This file include some port info and MongoDB connection variables used in server. The .env for server is shared in our slack channel.Client code also needs the .env file with Google Map API key (the one @knox153 sent on slack the other day). So we also need to move that into
Trecipe > packages > client
directory.