const fetch = require('node-fetch');

module.exports = async function (req, res, next) {

	try {
		if (req.query.remote) {
			// We're being asked to fetch a remote feed
			// NOTE: No, we don't limit what feeds the user can fetch

			const r = await fetch(req.query.remote);
			if (r && r.ok) {
				res.set("Content-Type", "application/xml");
				res.send(await r.text());
				return;
			}
		}
		res.status(400).send();
	} catch (err) {
		next(err);
	}
}
