aboutsummaryrefslogtreecommitdiff
path: root/src/server.js
diff options
context:
space:
mode:
authorMark Powers <markppowers0@gmail.com>2019-01-28 12:12:13 -0500
committerMark Powers <markppowers0@gmail.com>2019-01-28 12:12:13 -0500
commit80ee170990e78753d07779d59bdfe516c399d254 (patch)
treed058cb57340e4eb0b349b8ac65afd105760c7dd0 /src/server.js
parenta6f52178eb79da9415d2770f2245f2cea8a05808 (diff)
Make home page a feed
Diffstat (limited to 'src/server.js')
-rw-r--r--src/server.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/server.js b/src/server.js
index c94a91c..4a2a581 100644
--- a/src/server.js
+++ b/src/server.js
@@ -18,9 +18,12 @@ function setUpRoutes(models){
request(`http://localhost:8000?${req.url.split("?")[1]}`, function(error, response, body) {
});
})
- server.get('/posts.json', async (req, res, next) => {
+ server.get('/:type/posts.json', async (req, res, next) => {
try {
- var posts = await models.posts.findAll();
+ const { type } = req.params;
+ console.log(type);
+ console.log(req.params);
+ var posts = await models.posts.findAll({where: { type: type }});
posts = posts.map(x => x.get({ plain: true }));
for (const post of posts) {
const images = await models.pictures.findAll({ attributes: ["source"], where: { postId: post.id } }).map(x => x.source);