0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-31 17:22:45 +00:00

Merge branch 'metadata-api-endpoint' of https://github.com/naturalcrit/homebrewery into metadata-api-endpoint

This commit is contained in:
Víctor Losada Hernández
2024-07-19 08:58:21 +02:00
55 changed files with 16634 additions and 15692 deletions

View File

@@ -30,7 +30,7 @@ const junkBrewPipeline = [
{ $match : {
updatedAt : { $lt: Moment().subtract(30, 'days').toDate() },
lastViewed : { $lt: Moment().subtract(30, 'days').toDate() }
}},
} },
{ $project: { textBinSize: { $binarySize: '$textBin' } } },
{ $match: { textBinSize: { $lt: 140 } } },
{ $limit: 100 }

View File

@@ -25,7 +25,7 @@ const sanitizeBrew = (brew, accessType)=>{
brew.__v = undefined;
if(accessType !== 'edit' && accessType !== 'shareAuthor') {
brew.editId = undefined;
}
}
return brew;
};
@@ -350,13 +350,6 @@ app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, r
return next();
}));
//Print Page
app.get('/print/:id', asyncHandler(getBrew('share')), (req, res, next)=>{
sanitizeBrew(req.brew, 'share');
splitTextStyleAndMetadata(req.brew);
next();
});
//Account Page
app.get('/account', asyncHandler(async (req, res, next)=>{
const data = {};

View File

@@ -1,5 +1,4 @@
/* eslint-disable max-lines */
const _ = require('lodash');
const googleDrive = require('@googleapis/drive');
const { nanoid } = require('nanoid');
const token = require('./token.js');

View File

@@ -83,9 +83,9 @@ const api = {
if(accessType === 'edit' && (authorsExist && !(isAuthor || isInvited))) {
const accessError = { name: 'Access Error', status: 401 };
if(req.account){
throw { ...accessError, message: 'User is not an Author', HBErrorCode: '03', authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId};
throw { ...accessError, message: 'User is not an Author', HBErrorCode: '03', authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId };
}
throw { ...accessError, message: 'User is not logged in', HBErrorCode: '04', authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId};
throw { ...accessError, message: 'User is not logged in', HBErrorCode: '04', authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId };
}
// If after all of that we still don't have a brew, throw an exception