0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-27 09:22:44 +00:00

Initial commit

This commit is contained in:
Víctor Losada Hernández
2024-05-17 21:23:31 +02:00
parent fb299f898e
commit 243038474e

View File

@@ -195,6 +195,26 @@ app.get('/download/:id', asyncHandler(getBrew('share')), (req, res)=>{
res.status(200).send(brew.text);
});
app.get('/metadata/:id', asyncHandler(getBrew('share')), (req, res) => {
const { brew } = req;
sanitizeBrew(brew, 'share');
const fields = [ 'title', 'pageCount', 'description', 'authors', 'lang',
'published', 'views', 'shareId', 'createdAt', 'updatedAt',
'lastViewed', 'thumbnail', 'tags'
];
const metadata = fields.reduce((acc, field) => {
if (brew[field] !== undefined) acc[field] = brew[field];
return acc;
}, {});
console.log(metadata);
res.status(200).json(metadata);
});
//User Page
app.get('/user/:username', async (req, res, next)=>{
const ownAccount = req.account && (req.account.username == req.params.username);