aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Powers <mark@marks.kitchen>2020-05-08 02:52:43 +0000
committerMark Powers <mark@marks.kitchen>2020-05-08 02:52:43 +0000
commit317b8d97e3f3c27b17a9dd8f85de3acefb05566e (patch)
tree37088c9b1dcf3741d17b67c7aa132876302eb05a /src
parent17d71ddc5764f6af0e96106fd9288d0a2547e471 (diff)
parent94c8965a8e50d781555dde0ff0a5d1919db9aab3 (diff)
Merge branch 'master' of https://github.com/Mark-Powers/marks.kitchen
Diffstat (limited to 'src')
-rw-r--r--src/server.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/server.js b/src/server.js
index 0d01641..7a21525 100644
--- a/src/server.js
+++ b/src/server.js
@@ -5,6 +5,7 @@ const request = require('request');
const crypto = require('crypto');
const uuidv4 = require('uuid/v4');
const path = require('path');
+const rss = require('rss');
const Op = require('sequelize').Op;
@@ -284,6 +285,29 @@ function setUpRoutes(models, jwtFunctions, database) {
res.sendFile(__dirname + "/js/" + req.params.id);
});
+ server.get('/feed.xml', async (req, res) => {
+ var feed = new rss({
+ title: "Mark's Kitchen",
+ description: "Posts from marks.kitchen",
+ feed_url: "https://marks.kitchen/rss",
+ site_url: "https://marks.kitchen",
+ webMaster: "webmaster@marks.kitchen",
+ copyright: "Mark Powers"
+ })
+ var posts = await models.posts.findAll({
+ order: [['createdAt', 'DESC']]
+ });
+ posts = posts.map(x => x.get({ plain: true }));
+ posts.forEach(post =>{
+ feed.item({
+ title: post.createdAt.toString().substring(0, post.createdAt.toString().indexOf(" GMT")),
+ description: post.description,
+ date: post.createdAt,
+ url: `https://marks.kitchen/post/${post.type}/${post.id}`,
+ })
+ })
+ res.status(200).send(feed.xml({indent: true}))
+ })
}
module.exports = {