Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task 3. Debug in Node.js
Task description
Task check-list
Примечание: Не очень понятен момент с указыванием номера строки с ошибкой (после рефакторинга эти строки могут сильно поменяться), поэтому, чтобы избежать путаницы, я буду указывать номера строк в исходном репозитории, опираясь на данное сообщение:
А также, для удобства, приводить ссылки на эти самые строки.
Кроме этого, я оставлял комментарии в коде над местами, где были ошибки, чтобы было понятней смотреть на отрефакторенный код.
А еще можно посмотреть историю коммитов по очереди, они специально сделаны практически атомарно.
Completion of checklist:
Compilation errors:
❌ Missing export of Sequelize instance
✅ Add export of Sequelize instance
Line 16 (actually, you need to make a new line for it) at file
db.js❌ Missing export of Game model
✅ Add export of Game model
Line 1 at file
models/game.js❌ The sequelize package was used for User model import
✅ Use Sequelize instance from db.js for User model import
Line 2 at file
middleware/validate-session.js❌ Missing import of Express Router before usage
✅ Add import of Router from express package
Line 1 at file
controllers/usercontroller.js❌ Incorrect package name when importing bcryptjs package
✅ Use
bcryptjsinstead ofbcryptfor package nameLine 2 at file
controllers/usercontroller.js❌ Incorrect variable name was used for export game router
✅ Use
routerinstead ofroutersfor variable nameLine 116 at file
controllers/gamecontroller.jsLogical errors:
❌ Incorrect usage of body-parser middleware
✅ Use
.json()middleware ofbody-parserpackageLine 9 at file
app.js❌ Incorrect usage of validation middleware
✅ Use validation middleware only for
gamerouteLine 11 at file
app.js❌ PORT to listen on was not specified
✅ Use a
portfor app to listen on (e.g.4000, like said inconsole.log)Line 13 at file
app.js❌ Incorrect property name for User model (
passwordhash)✅ Use name
passwordHashinsteadLine 11 at file
controllers/usercontroller.js❌ Non-existing variable was used to pass games to response (
games)✅ Use variable
datainsteadLine 9 at file
controllers/gamecontroller.js❌ User Id was taken from request body in Game POST handler (
req.body.user.id)✅ Use
req.user.idinstead, which is set up in validation middlewareLine 42 at file
controllers/gamecontroller.js❌ Missing property
idofreq.user✅ Add property
idlikereq.user.idLine 73 at file
controllers/gamecontroller.jsRefactoring:
.send()was replaced with.json()in responses containing objectdotenvpackage