-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrss.js
42 lines (37 loc) · 1.09 KB
/
rss.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import express from 'express';
import {
generateRssForFeed,
generateRssForMicro,
generateRssForReading,
} from '../helpers/rss.js';
import { authenticated } from './auth.js';
const router = express.Router();
// Most builds should happen automatically as the DB is updated, but this function
// can kick off a manual build if need be.
router.post('/build', authenticated(), (req, res) => {
const { feed } = req.body;
if (!feed) {
return res.status(400).send({ message: 'Feed not provided' });
} else if (['reading', 'micro', 'feed', 'all'].indexOf(feed) === -1) {
return res.status(400).send({ message: 'Invalid feed type' });
}
// Just kick off the build; this will happen async
switch (feed) {
case 'reading':
generateRssForReading();
break;
case 'micro':
generateRssForMicro();
break;
case 'feed':
generateRssForFeed();
break;
case 'all':
generateRssForReading();
generateRssForMicro();
generateRssForFeed();
break;
}
res.status(200).send({ message: 'RSS build started' });
});
export default router;