-
Notifications
You must be signed in to change notification settings - Fork 6
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
#159206054 User can create articles #20
Conversation
seeders/20180731042502-demo-user.js
Outdated
}], {}), | ||
|
||
down: (queryInterface, Sequelize) => { | ||
return queryInterface.bulkDelete('Users', null, {}); |
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.
Expected indentation of 4 spaces but found 6 indent
seeders/20180731042502-demo-user.js
Outdated
updatedAt: '2018-07-27 13:36:27.179+01', | ||
}], {}), | ||
|
||
down: (queryInterface, Sequelize) => { |
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.
'Sequelize' is defined but never used no-unused-vars
Unexpected block statement surrounding arrow body; move the returned value immediately after the =>
arrow-body-style
seeders/20180731042502-demo-user.js
Outdated
@@ -0,0 +1,13 @@ | |||
module.exports = { | |||
up: (queryInterface, Sequelize) => queryInterface.bulkInsert('Users', [{ |
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.
'Sequelize' is defined but never used no-unused-vars
models/Article.js
Outdated
{ | ||
foreignKey: 'userId', | ||
onDelete: 'CASCADE', | ||
}); |
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.
Expected a newline before ')' function-paren-newline
models/Article.js
Outdated
}, {}); | ||
Article.associate = (models) => { | ||
// associations can be defined here | ||
Article.belongsTo(models.User, |
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.
Expected a newline after '(' function-paren-newline
index.js
Outdated
@@ -18,6 +18,13 @@ const debug = debugLog('index'); | |||
|
|||
// Create global app object | |||
const app = express(); | |||
console.log(config.cloudinary); |
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.
Unexpected console statement no-console
Pull Request Test Coverage Report for Build 552
💛 - Coveralls |
de5b2c9
to
e2252fe
Compare
routes/api/articleRoutes.js
Outdated
router.get('/articles/:slug', ArticleControllers.getArticle); | ||
router.get('/articles', ArticleControllers.listAllArticles); | ||
|
||
export default router; |
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.
Newline required at end of file but not found eol-last
models/Article.js
Outdated
onDelete: 'CASCADE', | ||
}); | ||
|
||
}; |
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.
Block must not be padded by blank lines padded-blocks
models/Article.js
Outdated
{ | ||
foreignKey: 'userId', | ||
onDelete: 'CASCADE', | ||
}); |
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.
Expected a newline before ')' function-paren-newline
models/Article.js
Outdated
|
||
Article.associate = (models) => { | ||
// associations can be defined here | ||
Article.belongsTo(models.User, |
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.
Expected a newline after '(' function-paren-newline
e2252fe
to
431acbb
Compare
routes/api/index.js
Outdated
@@ -1,6 +1,7 @@ | |||
import { Router } from 'express'; | |||
|
|||
import users from './users'; | |||
import articlesRoute from './articleRoutes'; |
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.
'articlesRoute' is defined but never used no-unused-vars
routes/api/index.js
Outdated
@@ -1,6 +1,7 @@ | |||
import { Router } from 'express'; | |||
|
|||
import users from './users'; | |||
import articlesRoute from './articleRoutes'; |
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.
'articlesRoute' is defined but never used no-unused-vars
431acbb
to
99568ec
Compare
controllers/ArticleController.js
Outdated
const articleObject = { | ||
title, description, body, tagList, imageUrl, userId | ||
}; | ||
/** check if image was provided in the request |
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.
The comment should be inside the border
/**
*comment to be made
*/
controllers/ArticleController.js
Outdated
.catch(() => createArticleHelper(res, articleObject)); | ||
} | ||
|
||
/** if there no image was provided go ahead to create the article */ |
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.
use // for single line comment
controllers/ArticleController.js
Outdated
attributes: { exclude: ['id', 'userId'] } | ||
}) | ||
.then((article) => { | ||
/** if the article does not exist */ |
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.
use // for single line comment
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.
Why do you think so? is there any impact it will have?
controllers/ArticleController.js
Outdated
|
||
return res.status(200).json({ article }); | ||
}) | ||
.catch(() => res.status(501).send('oops seems there is an error find the article')); |
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.
"seems there is an error finding the article"
if changes are made here I suppose it should also be effected on the test.
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 don't understand, can you please colour?
controllers/ArticleController.js
Outdated
attributes: { exclude: ['id', 'userId'] } | ||
}) | ||
.then((articles) => { | ||
/** check if there was no article created */ |
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.
use // for single line comment
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.
The response above as regards the comment format applies here
controllers/ArticleController.js
Outdated
if (!article) { | ||
return res.status(404).json({ | ||
errors: { | ||
body: [ |
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.
Can this be put on a single line? If so I suggest it should.
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.
The reason the code was broken down that way is for readability.
controllers/ArticleController.js
Outdated
/** check if there was no article created */ | ||
if (articles.length === 0) { | ||
return res.status(200).json({ | ||
message: 'Your request was successful but no articles created', |
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 suggest you just say "No articles found", as this is just a direct information to the user trying to retrieve articles
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.
Okay, yes but aren't we saying the same thing? To colour it, a user wants to get all the articles, the request was successful but there are no articles in the database yet.
controllers/ArticleController.js
Outdated
res.status(500).json({ | ||
errors: { | ||
body: [ | ||
'sorry there was an error updating this request', |
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 think it should be "sorry there was an error deleting the Article"
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.
thank you for spotting that out
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.
Review the suggestions here and make changes. Let me know if u have any information regarding this. cheers
99568ec
to
9f88bf1
Compare
models/Article.js
Outdated
Article.associate = (models) => { | ||
// associations can be defined here | ||
|
||
Article.belongsTo(models.User, |
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.
Expected a newline after '(' function-paren-newline
models/Article.js
Outdated
Article.associate = (models) => { | ||
// associations can be defined here | ||
|
||
Article.belongsTo(models.User, |
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.
Expected a newline after '(' function-paren-newline
7dbbcfd
to
e875c01
Compare
e875c01
to
21afeb2
Compare
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 think the slug title needs be changed from extensive hash generated value.
21afeb2
to
46b9abc
Compare
867632a
to
ec1ea07
Compare
ec1ea07
to
d978a68
Compare
d978a68
to
8a9a3b2
Compare
8a9a3b2
to
8da0286
Compare
8da0286
to
7d703cf
Compare
7d703cf
to
73a0ae1
Compare
73a0ae1
to
e10c9d8
Compare
e10c9d8
to
790509b
Compare
790509b
to
17ca01a
Compare
17ca01a
to
5b23b81
Compare
5b23b81
to
9765bb8
Compare
- Create model for article ft(article): create article - create helper function to generate slug from title feat(articles): update and delete artices - modify article model - add method to edit article - add method to delete article - restrict update to just (3) times [Delivers #159206054] feat(validate-input): Validate user input - validate user input - create user controller class - check if email is unique - check if username is unique - fix Hound CI file extension error - test for signup route [Delivers #159206048] chore(coverage): Increase coverage by 75% - add tests for user profile modifications - modify a utility function - modify validate.js [Delivers #159403248] ft(create-article): create user article - Write unit tests - Create model for article and association with user model - Create middleware to validate data to create article - Create helper function to create article - Create helper function to generate unique slugs - Add image upload feature using cloudinary - Create route and controller to create article - Create route and controller get an article using slug parameter - Create route and controller to get all articles [Delivers #159206054 #159206060]
9765bb8
to
2ed2ba5
Compare
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
What does this PR do?
Description of Task to be completed?
should be timestamped
How should this be manually tested?
In postman navigate to;
(POST)
http://localhost:3000/api/articles
- create article(GET)
http://localhost:3000/api/articles/:slug
- get an article(GET)
http://localhost:3000/api/articles
- get all articles(PUT)
http://localhost:3000/api/articles/:slug
- update an article by slug(DELETE)
http://localhost:3000/api/articles/:slug
- delete an article by slugAny background context you want to provide?
npm install
npm run dev
What are the relevant pivotal tracker stories?
https://www.pivotaltracker.com/story/show/159206054