diff --git a/src/backend/web/routes/feeds.js b/src/backend/web/routes/feeds.js index 20aefbff4d..18fed388c0 100644 --- a/src/backend/web/routes/feeds.js +++ b/src/backend/web/routes/feeds.js @@ -1,5 +1,6 @@ const express = require('express'); const Feed = require('../../data/feed'); +const { protect } = require('../authentication'); const { getFeeds } = require('../../utils/storage'); const { logger } = require('../../utils/logger'); @@ -51,4 +52,19 @@ feeds.get('/:id', async (req, res) => { } }); +feeds.post('/', protect, async (req, res) => { + const { newFeed, email } = req.body; + try { + /* check if email has a key in redis + if not create key + if user has a key in redis, check if feed already exists, (not sure how fast this is? or if its necessary), if not store feed in feeds. + */ + } catch (err) { + logger.error({ err }, 'Unable to add feed to redis'); + res.status(503).json({ + message: 'Unable to add feed to database.', + }); + } +}); + module.exports = feeds; diff --git a/src/backend/web/routes/users.js b/src/backend/web/routes/users.js new file mode 100644 index 0000000000..3ac0b6bdf7 --- /dev/null +++ b/src/backend/web/routes/users.js @@ -0,0 +1,22 @@ +const express = require('express'); + +const { logger } = require('../../utils/logger'); +const feeds = require('../../data/feeds'); +const { getFeeds } = require('../../utils/storage'); + +const router = express.Router(); + +router.get('/', async (req, res) => { + // this route will return all users. + /* [{id: "some-user-id", url: "/users/some-user-id", ...] */ +}); + +router.get('/:id', async (req, res) => { + // this route will return one user, and there list of feeds, this can be utilized in two places. One our search function, and + // two for our add feed component to show a list of feeds that have been attached to the user. + /* this should return + { id: "some-ud-id, url: "/users/someuserId/ (multiple URLs?)} + */ +}); + +module.exports = router;