-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Copy user service https://github.com/CS3219-AY2425S1/PeerPrep-UserService * Dockerise user-service Got user service to work in docker. It can only interface with an atlas cloud server currently. * Dockerise user-service User-service in docker can only communicate with an atlas mongodb server. * Merge with main Some files should have been committed in the previous commit. They are mostly to do with the dockerisation process. The merge with main might have messed with it. * Create .gitignore Somehow .gitignore was not commited with the last commit * Fix POST causing SEGSEGV Apparently bcrypt library cannot run on Docker's architecture. Change bcrypt to bcryptjs for compatibility. * Add test Test does not currently work * Basic user service Not connected to the login interface yet. Commiting to make a clean Pr. * Move user service folder * Fix minor user service issues * Remove orphan history file * Move `index.js` and `server.js` to the correct directory * Reduce use of port * Change login to use username * Fix user env typo --------- Co-authored-by: samuelim01 <samuelim01@gmail.com>
- Loading branch information
1 parent
154b802
commit c1861bb
Showing
34 changed files
with
4,148 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
# This is a sample environment configuration file. | ||
# Copy this file to .env and replace the placeholder values with your own. | ||
|
||
# Question Service | ||
QUESTION_DB_CLOUD_URI=<FILL-THIS-IN> | ||
QUESTION_DB_LOCAL_URI=mongodb://question-db:27017/question | ||
QUESTION_DB_USERNAME=user | ||
QUESTION_DB_PASSWORD=password | ||
|
||
NODE_ENV=development | ||
# User Service | ||
USER_SERVICE_CLOUD_URI=mongodb+srv://admin:<db_password>@cluster0.uo0vu.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0 | ||
USER_SERVICE_LOCAL_URI=mongodb://127.0.0.1:27017/peerprepUserServiceDB | ||
|
||
# Will use cloud MongoDB Atlas database | ||
ENV=PROD | ||
|
||
# Secret for creating JWT signature | ||
JWT_SECRET=you-can-replace-this-with-your-own-secret | ||
|
||
NODE_ENV=development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# Ignore IntelliJ IDEA project files | ||
.idea/ | ||
.env | ||
**/node_modules | ||
**/.env | ||
**/.idea | ||
# Vim temp files | ||
*~ | ||
*.swp | ||
*.swo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# User Service | ||
USER_SERVICE_CLOUD_URI=<cloud_uri> | ||
USER_SERVICE_LOCAL_URI=mongodb://127.0.0.1:27017/peerprepUserServiceDB | ||
PORT=3001 | ||
|
||
# Will use cloud MongoDB Atlas database | ||
ENV=PROD | ||
|
||
# Secret for creating JWT signature | ||
JWT_SECRET=you-can-replace-this-with-your-own-secret | ||
|
||
NODE_ENV=development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM node:20-alpine | ||
|
||
WORKDIR /app | ||
COPY package.json package-lock.json ./ | ||
RUN npm install | ||
COPY . . | ||
EXPOSE 3001 | ||
|
||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Setting up MongoDB Instance for User Service | ||
|
||
1. Visit the MongoDB Atlas Site [https://www.mongodb.com/atlas](https://www.mongodb.com/atlas) and click on "Try Free" | ||
|
||
2. Sign Up/Sign In with your preferred method. | ||
|
||
3. You will be greeted with welcome screens. Feel free to skip them till you reach the Dashboard page. | ||
|
||
4. Create a Database Deployment by clicking on the green `+ Create` Button: | ||
|
||
![alt text](./GuideAssets/Creation.png) | ||
|
||
5. Make selections as followings: | ||
|
||
- Select Shared Cluster | ||
- Select `aws` as Provider | ||
|
||
![alt text](./GuideAssets/Selection1.png) | ||
|
||
- Select `Singapore` for Region | ||
|
||
![alt text](./GuideAssets/Selection2.png) | ||
|
||
- Select `M0 Sandbox` Cluster (Free Forever - No Card Required) | ||
|
||
> Ensure to select M0 Sandbox, else you may be prompted to enter card details and may be charged! | ||
![alt text](./GuideAssets/Selection3.png) | ||
|
||
- Leave `Additional Settings` as it is | ||
|
||
- Provide a suitable name to the Cluster | ||
|
||
![alt text](./GuideAssets/Selection4.png) | ||
|
||
6. You will be prompted to set up Security for the database by providing `Username and Password`. Select that option and enter `Username` and `Password`. Please keep this safe as it will be used in User Service later on. | ||
|
||
![alt text](./GuideAssets/Security.png) | ||
|
||
7. Next, click on `Add my Current IP Address`. This will whiteliste your IP address and allow you to connect to the MongoDB Database. | ||
|
||
![alt text](./GuideAssets/Network.png) | ||
|
||
8. Click `Finish and Close` and the MongoDB Instance should be up and running. | ||
|
||
## Whitelisting All IP's | ||
|
||
1. Select `Network Access` from the left side pane on Dashboard. | ||
|
||
![alt text](./GuideAssets/SidePane.png) | ||
|
||
2. Click on the `Add IP Address` Button | ||
|
||
![alt text](./GuideAssets/AddIPAddress.png) | ||
|
||
3. Select the `ALLOW ACCESS FROM ANYWHERE` Button and Click `Confirm` | ||
|
||
![alt text](./GuideAssets/IPWhitelisting.png) | ||
|
||
Now, any IP Address can access this Database. |
Oops, something went wrong.