-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feedback #1
base: feedback
Are you sure you want to change the base?
Feedback #1
Changes from 4 commits
aa2719f
9ca6083
24080b8
f35043a
85e18dc
7f20285
ea3a187
5adc471
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# news-aggregator-api-BurningMoltres/.gitignore | ||
node_modules | ||
.tap | ||
.tap | ||
.env |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<!-- news-aggregator-api-BurningMoltres/README.md --> | ||
[![Open in Visual Studio Code](https://classroom.github.com/assets/open-in-vscode-2e0aaae1b6195c2367325f4f02e2d04e9abb55f0b24a779b69b11b9e10269abc.svg)](https://classroom.github.com/online_ide?assignment_repo_id=17675965&assignment_repo_type=AssignmentRepo) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
// news-aggregator-api-BurningMoltres/app.js | ||
const express = require('express'); | ||
const mongoose=require('mongoose'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure consistent spacing around the assignment operator for readability. Suggest changing |
||
const app = express(); | ||
const port = 3000; | ||
const UserRegistration=require('./routes/UserRegistration'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure consistent spacing around the assignment operator for readability. Suggest changing |
||
const UserLogin=require('./routes/UserLogin'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure consistent spacing around the assignment operator for readability. Suggest changing |
||
const UserPreferences=require('./routes/UserPreferences'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure consistent spacing around the assignment operator for readability. Suggest changing |
||
require('dotenv').config() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a good practice to handle possible errors when configuring the dotenv package, though not strictly necessary, it might improve robustness if it is ensured that the environment is properly loaded. |
||
|
||
app.use(express.json()); | ||
app.use(express.urlencoded({ extended: true })); | ||
|
||
app.listen(port, (err) => { | ||
if (err) { | ||
return console.log('Something bad happened', err); | ||
} | ||
console.log(`Server is listening on ${port}`); | ||
}); | ||
//verify jwttoken | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment |
||
|
||
mongoose.connect(process.env.MONGO_URL).then(()=>{ | ||
console.log("Connected To MongoDb"); | ||
app.listen(port, (err) => { | ||
if (err) { | ||
return console.log('Something bad happened', err); | ||
} | ||
console.log(`Server is listening on ${port}`); | ||
}); | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider handling errors that may occur while connecting to MongoDB to ensure any connection issues are logged or managed appropriately. |
||
|
||
app.use('/registerUser',UserRegistration); | ||
app.use('/userLogin',UserLogin); | ||
app.use('/preferences',UserPreferences); | ||
|
||
|
||
module.exports = app; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a newline at the end of the file to adhere to POSIX standards and improve compatibility with various tools. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// news-aggregator-api-BurningMoltres/models/user.js | ||
const mongoose=require('mongoose'); | ||
const courseSchema =new mongoose.Schema({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable |
||
username:{ | ||
type:String, | ||
required:true, | ||
minLength:5, | ||
maxLength:255, | ||
}, | ||
password:{ | ||
type:String, | ||
required:true, | ||
minLength:5, | ||
maxLength:255 | ||
}, | ||
email:{ | ||
type:String, | ||
required:true, | ||
minLength:5, | ||
maxLength:255 | ||
}, | ||
preferences:{ | ||
type:[], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
required:true, | ||
minLength:2, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
maxLength:255 | ||
} | ||
}) | ||
|
||
const User=mongoose.model("User",courseSchema); | ||
module.exports=User; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure there is a newline at the end of the file to follow the POSIX standard for text files. This can help avoid potential issues with version control systems or text processing tools. |
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.
It's generally a good practice to avoid leaving commented-out code (like the comment at line 1) in your committed files, unless it's necessary for documentation or temporary use. Consider removing it if it's not needed.