Files
blogger-nodejs/src/routes/syndication.js
max 0541b704db ExpressJS routes in different files
ExpressJS routes for the syndication stuff is now in a seperate file, will now do the other routes.

Signed-off-by: max <deadvey@localhost.localdomain>
2025-09-23 17:38:20 +01:00

86 lines
2.3 KiB
JavaScript

const express = require('express');
const config = require('../../config')
const data = require('../data')
const func = require('../functions')
const router = express.Router();
////////////////////// SYNDICATION ////////////////////////
// global RSS protocol gets
router.get("/rss", (req,res) => {
if (config.rss == false) {
res.render("partials/message", {
message: locale.rss_disabled,
config,
})
}
else {
res.setHeader('content-type', 'application/rss+xml');
res.render("syndication/global_rss", {
config,
posts: data.getdata('posts'),
func,
})
};
});
// user RSS protocol gets
router.get("/user/:username/rss", (req,res) => {
const username = req.params.username;
const userID = func.get_userID(username);
if (config.rss == false) {
res.render("partials/message", {
message: locale.rss_disabled,
config: config,
})
}
else {
res.setHeader('content-type', 'application/rss+xml');
res.render("syndication/user_rss", {
config,
posts: data.getdata('posts'),
func,
userID,
})
};
});
// global ATOM protocol gets
router.get("/atom", (req,res) => {
if (config.atom == false) {
res.render("partials/message", {
message: locale.atom_disabled,
config: config,
})
}
else {
res.setHeader('content-type', 'application/rss+xml');
res.render("syndication/global_atom", {
config,
posts: data.getdata('posts'),
func,
getUnixTime,
})
};
});
// user ATOM protocol gets
router.get("/user/:username/atom", (req,res) => {
const username = req.params.username;
const userID = func.get_userID(username);
if (config.atom == false) {
res.render("partials/message", {
message: locale.atom_disabled,
config: config,
})
}
else {
res.setHeader('content-type', 'application/rss+xml');
res.render("syndication/user_atom", {
config,
posts: data.getdata('posts'),
func,
userID,
getUnixTime,
})
};
});
module.exports = router;