Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routes -> Controllers -> Model fo r User Entity and Mongo DB set up #37

Merged
merged 2 commits into from
May 27, 2023

Conversation

AndyLiang1
Copy link
Contributor

Created the Router -> Controller -> Model Pattern for User. This PR also contains code to connect to our mongoDB.

Router calls controllers and is responsible for only exposing the route.
Controller contains business logic and accesses the DB. Controllers may also call other controllers.
Models define the schema of a collection (think of a table in SQL).

To test this PR, you need a .env file in the server folder. See the secrets channel.
In postman or google, put in http://localhost:5000/api/user to see the result.

Also, the Atlas Cluster now has all IPs whitelisted.

Comment on lines +1 to +6
{
"dependencies": {
"mongodb": "^5.5.0",
"mongoose": "^7.2.1"
}
}
Copy link
Member

@NLmeng NLmeng May 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might have accidentally install the dependencies in root. should be fine though. will be resolved in my pr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yea oops I only removed the node module

Comment on lines +1 to +6
require('dotenv').config()

const MONGO_USERNAME = process.env.MONGO_USERNAME || ''
const MONGO_PASSWORD = process.env.MONGO_PASSWORD || ''
const MONGO_URI = `mongodb+srv://${MONGO_USERNAME}:${MONGO_PASSWORD}@cluster0.4bflh41.mongodb.net/BugStormDB?retryWrites=true&w=majority`
const SERVER_PORT = process.env.PORT ? Number(process.env.PORT) : 5001
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed this to use port 5001, some mac has problems with port 5000 https://developer.apple.com/forums/thread/682332

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem :)

@L0Lmaker
Copy link
Contributor

We should also add local development option. Will create a new Issue for it.

@L0Lmaker L0Lmaker mentioned this pull request May 27, 2023
Copy link
Contributor

@L0Lmaker L0Lmaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@L0Lmaker L0Lmaker merged commit b4f0679 into main May 27, 2023
@L0Lmaker L0Lmaker deleted the Andy/2_Route_Controller_Model_For_User_And_DB_Setup branch May 27, 2023 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants