Skip to content

Commit

Permalink
Merge e6cffe3 into 665089d
Browse files Browse the repository at this point in the history
  • Loading branch information
itsgratien committed May 28, 2019
2 parents 665089d + e6cffe3 commit b5a7cef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
24 changes: 21 additions & 3 deletions controllers/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ class ArticleController {
} = req.query;
Article.findAndCountAll({
offset: (Number(page) - 1) * Number(limit),
limit
limit,
include: [
{
model: User,
as: 'authorfkey',
attributes: ['username', 'email', 'image', 'id', 'bio']
}
]
})
.then(articles => res.status(200).json({
status: 200,
Expand All @@ -89,7 +96,10 @@ class ArticleController {
limit
}
}))
.catch(error => res.status(500).json({ error }));
.catch((error) => {
console.log(error);
});
// .catch(error => res.status(500).json({ error }));
}

/**
Expand Down Expand Up @@ -174,7 +184,15 @@ class ArticleController {
const {
articleId
} = req.params;
const article = await Article.findByPk(articleId);
const article = await Article.findByPk(articleId, {
include: [
{
model: User,
as: 'authorfkey',
attributes: ['username', 'email', 'image', 'id', 'bio']
}
]
});
if (!article) {
throw new httpError(404, 'Sorry the requested resource could not be found.');
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"pg": "^7.9.0",
"pg-hstore": "^2.3.2",
"request": "^2.87.0",
"sequelize": "^5.1.0",
"sequelize": "^5.8.6",
"sequelize-cli": "^5.4.0",
"swagger-ui-express": "^4.0.2",
"underscore": "^1.9.1",
Expand All @@ -66,7 +66,7 @@
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.12.4",
"mocha": "^6.0.2",
"mocha": "^6.1.4",
"nock": "^10.0.6",
"nodemon": "^1.18.10",
"nyc": "^13.3.0"
Expand Down
2 changes: 1 addition & 1 deletion testingdata/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"password": "1Kig1L@20"
},
"googleValidToken": {
"access_token": "ya29.GlsSBxyqOjVZv7S402kdyhtzxSVOWHxSuYuCgyLpFTm16ifz14o4r54h8PaxBxsJjC3meeiz5JRyLA7biEmOO7yb2DHNNJg9HKQX9ibpdVbBOM8TGuS9nYiJ9vsQ"
"access_token": "ya29.GlsXB42q7CiCIWQEQMig2QWG_-laQRRNyEWjRAemWh6e7yWQv5kNtCh1mKUPYCFhtWVegnAI33MHJk_-uz5RMb71OPJglYun-PHXhFYjlzFhZkvshQjdTjtCuqkn"
},
"googleInvalidToken": {
"access_token": "ya29.Glv1Bvx5U-OTtL7Qxym4ugGyyRsxhEPoKe_Uz5cKKF_mLuGzrxHywvzLx_kgWKVfHZTKL2eg0K5oJ7RVKXwqDSG5-f5PUlo0iFz5jISJrVWsc5Ls7crApI-Uagjy"
Expand Down

0 comments on commit b5a7cef

Please sign in to comment.