First choose the project topic. The topics are from REST API lecture.
- Install mongodb
- Install nodejs
-
Create a
.env
file in the root directory and copy the content from.env.example
-
Make sure mongodb is running
-
Install dependencies:
yarn
-
Use this command for development mode:
yarn run start:dev
-
If you need to customize your env, take a look at
secrets.ts
file
Below are the steps that you need to finish in order to finish this module
- Explore the code base of the api folder, start with
server.ts
andapp.ts
- Client folder is for the react frontend. Start with
api
first before moving on toclient
- Create all the mongoose schema for your ERD
- Create CRUD endpoints for all the schema
- Separate the routers and controller, controller goes into the controller folders. Controllers only handles request and response, and will call service to process business logics.
- Create more controller for your app if needed. Eg: borrow books, add product to order
- For business logic like saving data to database, filtering, searching or updating, these are services and goes into services folder
- Add authentication middleware using passport, google and jwt strategy
- Add tests for your controllers and services. Remember to create the jwt token for your tests, because if your controller is protected, then the test should send the token also
- Clone the repo. It contatins folder api, client, docker.compose.yml, .github/workflows (for CI/DC action) and README.md
- Install node_module by runing commnad in api and client folder
npm install
- create .env file in root file of client folder and paste
REACT_APP_BACKEND=http://localhost:5000/api/v1
- create .env file in root file of api folder and paste. this will allow to connect mongodb and some of secret veriable. To get connected with mongodb run locally you mongodb Here you can find instruction to install and run mongodb locally Mongodb install and run instruction
# Get this from mongodb atlas after you've logged in and created a database
MONGODB_URI_LOCAL=mongodb://localhost:27017/give_some_name_for_db
# Put lots of randomness in these
JWT_SECRET=ashdfjhasdlkjfhalksdjhflak
JWT_EXPIRES_IN=90d
JWT_COOKIE_EXPIRES_IN=90
# Application Port - express server listens on this port (default 3000).
PORT = 5000
GOOGLE_CLIENT_ID=(create your own google client variable by visiting to google cloud platform)
- Run cmd in terminal in client folder
npm start
- Run cmd in terminal in api folder
npm run start:dev