|
1 | 1 | # PeerPrep Backend
|
2 | 2 |
|
3 |
| -> Set-up either a local or cloud MongoDB first, before proceeding to each microservice for more instructions. |
| 3 | +> Before proceeding to each microservice for more instructions: |
| 4 | +
|
| 5 | +1. Set-up either a local or cloud MongoDB. |
| 6 | + |
| 7 | +2. Set-up Firebase. |
4 | 8 |
|
5 | 9 | ## Setting-up local MongoDB (only if you are using Docker)
|
6 | 10 |
|
7 | 11 | 1. In the `backend` directory, create a copy of the `.env.sample` file and name it `.env`.
|
8 | 12 |
|
9 | 13 | 2. To set up credentials for the MongoDB database, update `MONGO_INITDB_ROOT_USERNAME`, `MONGO_INITDB_ROOT_PASSWORD` of the `.env` file.
|
10 | 14 |
|
11 |
| -3. Your local Mongo URI will be `mongodb://<MONGO_INITDB_ROOT_USERNAME>:<MONGO_INITDB_ROOT_PASSWORD>@mongo:27017/`. Take note of it as we will be using in the `.env` file in the various microservices later on. |
| 15 | +3. Your local Mongo URI will be `mongodb://<MONGO_INITDB_ROOT_USERNAME>:<MONGO_INITDB_ROOT_PASSWORD>@mongo:27017/`. Take note of it as we will be using in the `.env` files in the various microservices later on. |
12 | 16 |
|
13 | 17 | 4. You can view the MongoDB collections locally using Mongo Express. To set up Mongo Express, update `ME_CONFIG_BASICAUTH_USERNAME` and `ME_CONFIG_BASICAUTH_PASSWORD`. The username and password will be the login credentials when you access Mongo Express at http://localhost:8081.
|
14 | 18 |
|
|
87 | 91 |
|
88 | 92 | 
|
89 | 93 |
|
90 |
| -13. Your cloud Mongo URI will be the string you copied earlier. Take note of it as we will be using in the `.env` file in the various microservices later on. |
| 94 | +13. Your cloud Mongo URI will be the string you copied earlier. Take note of it as we will be using in the `.env` files in the various microservices later on. |
| 95 | + |
| 96 | +## Setting-up Firebase |
| 97 | + |
| 98 | +1. Go to https://console.firebase.google.com/u/0/. |
| 99 | + |
| 100 | +2. Create a project and choose a project name. Navigate to `Storage` and click on it to activate it. |
| 101 | + |
| 102 | +3. Select `Start in production mode` and your preferred cloud storage region. |
| 103 | + |
| 104 | +4. After Storage is created, go to `Rules` section and set rule to: |
| 105 | + |
| 106 | + ``` |
| 107 | + rules_version = '2'; |
| 108 | + service firebase.storage { |
| 109 | + match /b/{bucket}/o { |
| 110 | + match /{allPaths=**} { |
| 111 | + allow read: if true; |
| 112 | + allow write: if request.auth != null; |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + ``` |
| 117 | + |
| 118 | + This rule ensures that only verified users can upload images while ensuring that URLs of images are public. Remember to click `Publish` to save changes. |
| 119 | + |
| 120 | +5. Go to `Settings`, `Project settings`, `Service accounts` and click `Generate new private key`. This will download a `.json` file, which will contain your credentials. |
| 121 | + |
| 122 | +6. You will need to update the following variables in the `.env` files of the various microservices later on. |
| 123 | + - `FIREBASE_PROJECT_ID` is the value of `project_id` found in the downloaded json file. |
| 124 | + - `FIREBASE_PRIVATE_KEY` is the value of `private_key` found in the downloaded json file. |
| 125 | + - `FIREBASE_CLIENT_EMAIL` is the value of `client_email` found in the downloaded json file. |
| 126 | + - `FIREBASE_STORAGE_BUCKET` is the folder path of the Storage. It should look something like `gs://<appname>.appspot.com`. |
0 commit comments