-
Notifications
You must be signed in to change notification settings - Fork 2
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
Routes -> Controllers -> Model fo r User Entity and Mongo DB set up #37
Conversation
{ | ||
"dependencies": { | ||
"mongodb": "^5.5.0", | ||
"mongoose": "^7.2.1" | ||
} | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem :)
We should also add local development option. Will create a new Issue for it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.