mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-14 04:12:43 +00:00
Merge branch 'master' into google-document-stubs
This commit is contained in:
4318
package-lock.json
generated
4318
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@@ -51,20 +51,20 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.17.9",
|
"@babel/core": "^7.17.10",
|
||||||
"@babel/plugin-transform-runtime": "^7.17.0",
|
"@babel/plugin-transform-runtime": "^7.17.10",
|
||||||
"@babel/preset-env": "^7.16.11",
|
"@babel/preset-env": "^7.17.10",
|
||||||
"@babel/preset-react": "^7.16.7",
|
"@babel/preset-react": "^7.16.7",
|
||||||
"body-parser": "^1.20.0",
|
"body-parser": "^1.20.0",
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.1",
|
||||||
"codemirror": "^5.65.2",
|
"codemirror": "^5.65.3",
|
||||||
"cookie-parser": "^1.4.6",
|
"cookie-parser": "^1.4.6",
|
||||||
"create-react-class": "^15.7.0",
|
"create-react-class": "^15.7.0",
|
||||||
"dedent-tabs": "^0.10.1",
|
"dedent-tabs": "^0.10.1",
|
||||||
"express": "^4.17.3",
|
"express": "^4.18.1",
|
||||||
"express-async-handler": "^1.2.0",
|
"express-async-handler": "^1.2.0",
|
||||||
"express-static-gzip": "2.1.5",
|
"express-static-gzip": "2.1.5",
|
||||||
"fs-extra": "10.0.1",
|
"fs-extra": "10.1.0",
|
||||||
"googleapis": "100.0.0",
|
"googleapis": "100.0.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"jwt-simple": "^0.5.6",
|
"jwt-simple": "^0.5.6",
|
||||||
@@ -73,10 +73,10 @@
|
|||||||
"marked": "4.0.14",
|
"marked": "4.0.14",
|
||||||
"marked-extended-tables": "^1.0.3",
|
"marked-extended-tables": "^1.0.3",
|
||||||
"markedLegacy": "npm:marked@^0.3.19",
|
"markedLegacy": "npm:marked@^0.3.19",
|
||||||
"moment": "^2.29.2",
|
"moment": "^2.29.3",
|
||||||
"mongoose": "^6.2.11",
|
"mongoose": "^6.3.1",
|
||||||
"nanoid": "3.3.2",
|
"nanoid": "3.3.3",
|
||||||
"nconf": "^0.11.4",
|
"nconf": "^0.12.0",
|
||||||
"query-string": "7.1.1",
|
"query-string": "7.1.1",
|
||||||
"react": "^16.14.0",
|
"react": "^16.14.0",
|
||||||
"react-dom": "^16.14.0",
|
"react-dom": "^16.14.0",
|
||||||
@@ -87,9 +87,9 @@
|
|||||||
"vitreum": "git+https://git@github.com/calculuschild/vitreum.git"
|
"vitreum": "git+https://git@github.com/calculuschild/vitreum.git"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.13.0",
|
"eslint": "^8.14.0",
|
||||||
"eslint-plugin-react": "^7.29.4",
|
"eslint-plugin-react": "^7.29.4",
|
||||||
"jest": "^27.5.1",
|
"jest": "^28.0.3",
|
||||||
"supertest": "^6.2.2"
|
"supertest": "^6.2.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,20 @@ app.get('/download/:id', asyncHandler(getBrew('share')), (req, res)=>{
|
|||||||
app.get('/user/:username', async (req, res, next)=>{
|
app.get('/user/:username', async (req, res, next)=>{
|
||||||
const ownAccount = req.account && (req.account.username == req.params.username);
|
const ownAccount = req.account && (req.account.username == req.params.username);
|
||||||
|
|
||||||
let brews = await HomebrewModel.getByUser(req.params.username, ownAccount)
|
const fields = [
|
||||||
|
'title',
|
||||||
|
'pageCount',
|
||||||
|
'description',
|
||||||
|
'authors',
|
||||||
|
'views',
|
||||||
|
'shareId',
|
||||||
|
'editId',
|
||||||
|
'createdAt',
|
||||||
|
'updatedAt',
|
||||||
|
'lastViewed'
|
||||||
|
];
|
||||||
|
|
||||||
|
let brews = await HomebrewModel.getByUser(req.params.username, ownAccount, fields)
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ HomebrewSchema.statics.increaseView = async function(query) {
|
|||||||
return brew;
|
return brew;
|
||||||
};
|
};
|
||||||
|
|
||||||
HomebrewSchema.statics.get = function(query){
|
HomebrewSchema.statics.get = function(query, fields=null){
|
||||||
return new Promise((resolve, reject)=>{
|
return new Promise((resolve, reject)=>{
|
||||||
Homebrew.find(query, (err, brews)=>{
|
Homebrew.find(query, fields, null, (err, brews)=>{
|
||||||
if(err || !brews.length) return reject('Can not find brew');
|
if(err || !brews.length) return reject('Can not find brew');
|
||||||
if(!_.isNil(brews[0].textBin)) { // Uncompress zipped text field
|
if(!_.isNil(brews[0].textBin)) { // Uncompress zipped text field
|
||||||
unzipped = zlib.inflateRawSync(brews[0].textBin);
|
unzipped = zlib.inflateRawSync(brews[0].textBin);
|
||||||
@@ -53,13 +53,13 @@ HomebrewSchema.statics.get = function(query){
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
HomebrewSchema.statics.getByUser = function(username, allowAccess=false){
|
HomebrewSchema.statics.getByUser = function(username, allowAccess=false, fields=null){
|
||||||
return new Promise((resolve, reject)=>{
|
return new Promise((resolve, reject)=>{
|
||||||
const query = { authors: username, published: true };
|
const query = { authors: username, published: true };
|
||||||
if(allowAccess){
|
if(allowAccess){
|
||||||
delete query.published;
|
delete query.published;
|
||||||
}
|
}
|
||||||
Homebrew.find(query).lean().exec((err, brews)=>{ //lean() converts results to JSObjects
|
Homebrew.find(query, fields).lean().exec((err, brews)=>{ //lean() converts results to JSObjects
|
||||||
if(err) return reject('Can not find brew');
|
if(err) return reject('Can not find brew');
|
||||||
return resolve(brews);
|
return resolve(brews);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user