Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redaction #29

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"restricted": ["politics"]
}
21 changes: 7 additions & 14 deletions server/controller/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// What would the channel/:channelID return? => I'm thinking we don't need this?
// Are we querying for a specific message?
// How do we handle pagination for messages?

const data = require('../../data.json')
const express = require('express');
const router = express.Router();
const { example } = require('../../db/model/channel');
Expand All @@ -17,26 +17,19 @@ const {
router.get('/', async (req, res) => {
try {
const results = await fetchChannels();
results = results.filter(result => {
return !data.restrict.includes(result.name);
});
res.status(200).send(results);
} catch (err) {
res.status(404).send(err);
}
});

router.get('/:channelId/messages', async (req, res) => {
const { channelId } = req.params;
try {
const results = await fetchMessages(channelId);
res.status(200).send(results);
} catch (err) {
res.status(404).send(err);
}
});

router.get('/:channelId/messages', async (req, res) => {
const { channelId } = req.params;
router.get('/:channelName/messages', async (req, res) => {
const { channelName } = req.params;
try {
const results = await fetchMessages(channelId);
const results = await fetchMessages(channelName);
res.status(200).send(results);
} catch (err) {
res.status(404).send(err);
Expand Down
1 change: 1 addition & 0 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ app.use(cors());
app.get('/', (req, res) => {
res.send('example endpoint');
});

// OpenAPI documentation
app.use('/docs', swaggerUi.serve);
app.get('/docs', swaggerUi.setup(
Expand Down