Update index.js

This commit is contained in:
The Ghost of FOSS' Past 2024-11-06 20:02:59 +00:00
parent 8b5a0d9b54
commit ebe67484e7

View file

@ -120,7 +120,7 @@ app.post('/users/:username/posts', authenticate, (req, res) => {
res.status(201).json(post); res.status(201).json(post);
}); });
// Route to get a users posts // Route to get a user's posts
app.get('/users/:username/posts', authenticate, (req, res) => { app.get('/users/:username/posts', authenticate, (req, res) => {
const { username } = req.params; const { username } = req.params;
@ -185,7 +185,7 @@ activityPubRouter.get('/users/:username/outbox', (req, res) => {
return res.status(404).json({ error: 'User not found' }); return res.status(404).json({ error: 'User not found' });
} }
// Fetch posts from this users outbox (from the DB) // Fetch posts from this user's outbox (from the DB)
const userPosts = Object.values(db.get("posts") || {}).filter(post => post.author.username === username); const userPosts = Object.values(db.get("posts") || {}).filter(post => post.author.username === username);
res.json(userPosts); res.json(userPosts);
}); });