mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-26 20:22:42 +00:00
Merge branch 'master' into client-server-version-mismatch-middleware
This commit is contained in:
10
changelog.md
10
changelog.md
@@ -59,9 +59,19 @@ For a full record of development, visit our [Github Page](https://github.com/nat
|
||||
|
||||
### v3.6.0
|
||||
{{taskList
|
||||
##### calculuschild
|
||||
|
||||
* [x] Fix Google Drive brews sometimes duplicating
|
||||
|
||||
Fixes issues [#2603](https://github.com/naturalcrit/homebrewery/issues/2603)
|
||||
|
||||
##### Jeddai
|
||||
|
||||
* [x] Add unit tests with full coverage for the Homebrewery API
|
||||
|
||||
##### G-Ambatte
|
||||
|
||||
* [x] Add Themes directory to development server watchlist.
|
||||
}}
|
||||
|
||||
### Friday 23/12/2022 - v3.5.0
|
||||
|
||||
96
package-lock.json
generated
96
package-lock.json
generated
@@ -10,7 +10,7 @@
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.20.7",
|
||||
"@babel/core": "^7.20.12",
|
||||
"@babel/plugin-transform-runtime": "^7.19.6",
|
||||
"@babel/preset-env": "^7.19.4",
|
||||
"@babel/preset-react": "^7.18.6",
|
||||
@@ -33,7 +33,7 @@
|
||||
"marked-extended-tables": "^1.0.5",
|
||||
"markedLegacy": "npm:marked@^0.3.19",
|
||||
"moment": "^2.29.4",
|
||||
"mongoose": "^6.8.2",
|
||||
"mongoose": "^6.8.3",
|
||||
"nanoid": "3.3.4",
|
||||
"nconf": "^0.12.0",
|
||||
"npm": "^8.10.0",
|
||||
@@ -1452,24 +1452,24 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/core": {
|
||||
"version": "7.20.7",
|
||||
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.20.7.tgz",
|
||||
"integrity": "sha512-t1ZjCluspe5DW24bn2Rr1CDb2v9rn/hROtg9a2tmd0+QYf4bsloYfLQzjG4qHPNMhWtKdGC33R5AxGR2Af2cBw==",
|
||||
"version": "7.20.12",
|
||||
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.20.12.tgz",
|
||||
"integrity": "sha512-XsMfHovsUYHFMdrIHkZphTN/2Hzzi78R08NuHfDBehym2VsPDL6Zn/JAD/JQdnRvbSsbQc4mVaU1m6JgtTEElg==",
|
||||
"dependencies": {
|
||||
"@ampproject/remapping": "^2.1.0",
|
||||
"@babel/code-frame": "^7.18.6",
|
||||
"@babel/generator": "^7.20.7",
|
||||
"@babel/helper-compilation-targets": "^7.20.7",
|
||||
"@babel/helper-module-transforms": "^7.20.7",
|
||||
"@babel/helper-module-transforms": "^7.20.11",
|
||||
"@babel/helpers": "^7.20.7",
|
||||
"@babel/parser": "^7.20.7",
|
||||
"@babel/template": "^7.20.7",
|
||||
"@babel/traverse": "^7.20.7",
|
||||
"@babel/traverse": "^7.20.12",
|
||||
"@babel/types": "^7.20.7",
|
||||
"convert-source-map": "^1.7.0",
|
||||
"debug": "^4.1.0",
|
||||
"gensync": "^1.0.0-beta.2",
|
||||
"json5": "^2.2.1",
|
||||
"json5": "^2.2.2",
|
||||
"semver": "^6.3.0"
|
||||
},
|
||||
"engines": {
|
||||
@@ -1676,9 +1676,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/helper-module-transforms": {
|
||||
"version": "7.20.7",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.20.7.tgz",
|
||||
"integrity": "sha512-FNdu7r67fqMUSVuQpFQGE6BPdhJIhitoxhGzDbAXNcA07uoVG37fOiMk3OSV8rEICuyG6t8LGkd9EE64qIEoIA==",
|
||||
"version": "7.20.11",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.20.11.tgz",
|
||||
"integrity": "sha512-uRy78kN4psmji1s2QtbtcCSaj/LILFDp0f/ymhpQH5QY3nljUZCaNWz9X1dEj/8MBdBEFECs7yRhKn8i7NjZgg==",
|
||||
"dependencies": {
|
||||
"@babel/helper-environment-visitor": "^7.18.9",
|
||||
"@babel/helper-module-imports": "^7.18.6",
|
||||
@@ -1686,7 +1686,7 @@
|
||||
"@babel/helper-split-export-declaration": "^7.18.6",
|
||||
"@babel/helper-validator-identifier": "^7.19.1",
|
||||
"@babel/template": "^7.20.7",
|
||||
"@babel/traverse": "^7.20.7",
|
||||
"@babel/traverse": "^7.20.10",
|
||||
"@babel/types": "^7.20.7"
|
||||
},
|
||||
"engines": {
|
||||
@@ -3047,9 +3047,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/traverse": {
|
||||
"version": "7.20.8",
|
||||
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.8.tgz",
|
||||
"integrity": "sha512-/RNkaYDeCy4MjyV70+QkSHhxbvj2JO/5Ft2Pa880qJOG8tWrqcT/wXUuCCv43yogfqPzHL77Xu101KQPf4clnQ==",
|
||||
"version": "7.20.12",
|
||||
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.12.tgz",
|
||||
"integrity": "sha512-MsIbFN0u+raeja38qboyF8TIT7K0BFzz/Yd/77ta4MsUsmP2RAnidIlwq7d5HFQrH/OZJecGV6B71C4zAgpoSQ==",
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.18.6",
|
||||
"@babel/generator": "^7.20.7",
|
||||
@@ -9770,9 +9770,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/json5": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
|
||||
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
||||
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
|
||||
"bin": {
|
||||
"json5": "lib/cli.js"
|
||||
},
|
||||
@@ -9863,9 +9863,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/kareem": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.0.tgz",
|
||||
"integrity": "sha512-rVBUGGwvqg130iwYu8k7lutHuDBFj1yGRdnlE44wEhxAmFBad1zcL66PdWC1raw3tIObY6XWhtv3VL04xQb/cg==",
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz",
|
||||
"integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA==",
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
@@ -10395,12 +10395,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/mongoose": {
|
||||
"version": "6.8.2",
|
||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.8.2.tgz",
|
||||
"integrity": "sha512-cIato5N2w/QuJkkh0w4nyf7ty7DqmmP/W8/6PFSM0DrzbxIMlr6VN15LBIceTSJIxbznNl2Mlbh9Rm4sokMw+A==",
|
||||
"version": "6.8.3",
|
||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.8.3.tgz",
|
||||
"integrity": "sha512-qrVWefJK+wFNBH0ALV+oiyJ+FN42O/BqvHFmlFJJ2LKuNmQEOE0JV8FCxnZqtanwbHs4i+k/SkjhtC+C01haaw==",
|
||||
"dependencies": {
|
||||
"bson": "^4.7.0",
|
||||
"kareem": "2.5.0",
|
||||
"kareem": "2.5.1",
|
||||
"mongodb": "4.12.1",
|
||||
"mpath": "0.9.0",
|
||||
"mquery": "4.0.3",
|
||||
@@ -17777,24 +17777,24 @@
|
||||
"integrity": "sha512-KZXo2t10+/jxmkhNXc7pZTqRvSOIvVv/+lJwHS+B2rErwOyjuVRh60yVpb7liQ1U5t7lLJ1bz+t8tSypUZdm0g=="
|
||||
},
|
||||
"@babel/core": {
|
||||
"version": "7.20.7",
|
||||
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.20.7.tgz",
|
||||
"integrity": "sha512-t1ZjCluspe5DW24bn2Rr1CDb2v9rn/hROtg9a2tmd0+QYf4bsloYfLQzjG4qHPNMhWtKdGC33R5AxGR2Af2cBw==",
|
||||
"version": "7.20.12",
|
||||
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.20.12.tgz",
|
||||
"integrity": "sha512-XsMfHovsUYHFMdrIHkZphTN/2Hzzi78R08NuHfDBehym2VsPDL6Zn/JAD/JQdnRvbSsbQc4mVaU1m6JgtTEElg==",
|
||||
"requires": {
|
||||
"@ampproject/remapping": "^2.1.0",
|
||||
"@babel/code-frame": "^7.18.6",
|
||||
"@babel/generator": "^7.20.7",
|
||||
"@babel/helper-compilation-targets": "^7.20.7",
|
||||
"@babel/helper-module-transforms": "^7.20.7",
|
||||
"@babel/helper-module-transforms": "^7.20.11",
|
||||
"@babel/helpers": "^7.20.7",
|
||||
"@babel/parser": "^7.20.7",
|
||||
"@babel/template": "^7.20.7",
|
||||
"@babel/traverse": "^7.20.7",
|
||||
"@babel/traverse": "^7.20.12",
|
||||
"@babel/types": "^7.20.7",
|
||||
"convert-source-map": "^1.7.0",
|
||||
"debug": "^4.1.0",
|
||||
"gensync": "^1.0.0-beta.2",
|
||||
"json5": "^2.2.1",
|
||||
"json5": "^2.2.2",
|
||||
"semver": "^6.3.0"
|
||||
}
|
||||
},
|
||||
@@ -17947,9 +17947,9 @@
|
||||
}
|
||||
},
|
||||
"@babel/helper-module-transforms": {
|
||||
"version": "7.20.7",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.20.7.tgz",
|
||||
"integrity": "sha512-FNdu7r67fqMUSVuQpFQGE6BPdhJIhitoxhGzDbAXNcA07uoVG37fOiMk3OSV8rEICuyG6t8LGkd9EE64qIEoIA==",
|
||||
"version": "7.20.11",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.20.11.tgz",
|
||||
"integrity": "sha512-uRy78kN4psmji1s2QtbtcCSaj/LILFDp0f/ymhpQH5QY3nljUZCaNWz9X1dEj/8MBdBEFECs7yRhKn8i7NjZgg==",
|
||||
"requires": {
|
||||
"@babel/helper-environment-visitor": "^7.18.9",
|
||||
"@babel/helper-module-imports": "^7.18.6",
|
||||
@@ -17957,7 +17957,7 @@
|
||||
"@babel/helper-split-export-declaration": "^7.18.6",
|
||||
"@babel/helper-validator-identifier": "^7.19.1",
|
||||
"@babel/template": "^7.20.7",
|
||||
"@babel/traverse": "^7.20.7",
|
||||
"@babel/traverse": "^7.20.10",
|
||||
"@babel/types": "^7.20.7"
|
||||
}
|
||||
},
|
||||
@@ -18847,9 +18847,9 @@
|
||||
}
|
||||
},
|
||||
"@babel/traverse": {
|
||||
"version": "7.20.8",
|
||||
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.8.tgz",
|
||||
"integrity": "sha512-/RNkaYDeCy4MjyV70+QkSHhxbvj2JO/5Ft2Pa880qJOG8tWrqcT/wXUuCCv43yogfqPzHL77Xu101KQPf4clnQ==",
|
||||
"version": "7.20.12",
|
||||
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.12.tgz",
|
||||
"integrity": "sha512-MsIbFN0u+raeja38qboyF8TIT7K0BFzz/Yd/77ta4MsUsmP2RAnidIlwq7d5HFQrH/OZJecGV6B71C4zAgpoSQ==",
|
||||
"requires": {
|
||||
"@babel/code-frame": "^7.18.6",
|
||||
"@babel/generator": "^7.20.7",
|
||||
@@ -24053,9 +24053,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"json5": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
|
||||
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA=="
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
||||
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="
|
||||
},
|
||||
"jsonfile": {
|
||||
"version": "6.1.0",
|
||||
@@ -24120,9 +24120,9 @@
|
||||
"integrity": "sha512-40aUybvhH9t2h71ncA1/1SbtTNCVZHgsTsTgqPUxGWDmUDrXyDf2wMNQKEbdBjbf4AI+fQhbECNTV6lWxQKUzg=="
|
||||
},
|
||||
"kareem": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.0.tgz",
|
||||
"integrity": "sha512-rVBUGGwvqg130iwYu8k7lutHuDBFj1yGRdnlE44wEhxAmFBad1zcL66PdWC1raw3tIObY6XWhtv3VL04xQb/cg=="
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz",
|
||||
"integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA=="
|
||||
},
|
||||
"kind-of": {
|
||||
"version": "4.0.0",
|
||||
@@ -24533,12 +24533,12 @@
|
||||
}
|
||||
},
|
||||
"mongoose": {
|
||||
"version": "6.8.2",
|
||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.8.2.tgz",
|
||||
"integrity": "sha512-cIato5N2w/QuJkkh0w4nyf7ty7DqmmP/W8/6PFSM0DrzbxIMlr6VN15LBIceTSJIxbznNl2Mlbh9Rm4sokMw+A==",
|
||||
"version": "6.8.3",
|
||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.8.3.tgz",
|
||||
"integrity": "sha512-qrVWefJK+wFNBH0ALV+oiyJ+FN42O/BqvHFmlFJJ2LKuNmQEOE0JV8FCxnZqtanwbHs4i+k/SkjhtC+C01haaw==",
|
||||
"requires": {
|
||||
"bson": "^4.7.0",
|
||||
"kareem": "2.5.0",
|
||||
"kareem": "2.5.1",
|
||||
"mongodb": "4.12.1",
|
||||
"mpath": "0.9.0",
|
||||
"mquery": "4.0.3",
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"quick": "node scripts/quick.js",
|
||||
"build": "node scripts/buildHomebrew.js",
|
||||
"buildall": "node scripts/buildHomebrew.js && node scripts/buildAdmin.js",
|
||||
"builddev": "node scripts/buildHomebrew.js --dev",
|
||||
"lint": "eslint --fix **/*.{js,jsx}",
|
||||
"lint:dry": "eslint **/*.{js,jsx}",
|
||||
"circleci": "npm test && eslint **/*.{js,jsx} --max-warnings=0",
|
||||
@@ -67,7 +68,7 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.20.7",
|
||||
"@babel/core": "^7.20.12",
|
||||
"@babel/plugin-transform-runtime": "^7.19.6",
|
||||
"@babel/preset-env": "^7.19.4",
|
||||
"@babel/preset-react": "^7.18.6",
|
||||
@@ -90,7 +91,7 @@
|
||||
"marked-extended-tables": "^1.0.5",
|
||||
"markedLegacy": "npm:marked@^0.3.19",
|
||||
"moment": "^2.29.4",
|
||||
"mongoose": "^6.8.2",
|
||||
"mongoose": "^6.8.3",
|
||||
"nanoid": "3.3.4",
|
||||
"nconf": "^0.12.0",
|
||||
"npm": "^8.10.0",
|
||||
|
||||
@@ -136,6 +136,6 @@ fs.emptyDirSync('./build');
|
||||
if(isDev){
|
||||
livereload('./build');
|
||||
watchFile('./server.js', {
|
||||
watch : ['./client', './server'] // Watch additional folders if you want
|
||||
watch : ['./client', './server', './themes'] // Watch additional folders if you want
|
||||
});
|
||||
}
|
||||
|
||||
@@ -54,11 +54,10 @@ const api = {
|
||||
let googleError;
|
||||
const googleBrew = await GoogleActions.getGoogleBrew(googleId || stub?.googleId, id, accessType)
|
||||
.catch((err)=>{
|
||||
console.warn(err);
|
||||
googleError = err;
|
||||
});
|
||||
// If we can't find the google brew and there is a google id for the brew, throw an error.
|
||||
if(!googleBrew) throw googleError;
|
||||
// Throw any error caught while attempting to retrieve Google brew.
|
||||
if(googleError) throw googleError;
|
||||
// Combine the Homebrewery stub with the google brew, or if the stub doesn't exist just use the google brew
|
||||
stub = stub ? _.assign({ ...api.excludeStubProps(stub), stubbed: true }, api.excludeGoogleProps(googleBrew)) : googleBrew;
|
||||
}
|
||||
@@ -77,11 +76,13 @@ If you believe you should have access to this brew, ask the file owner to invite
|
||||
}
|
||||
|
||||
// Clean up brew: fill in missing fields with defaults / fix old invalid values
|
||||
stub.tags = stub.tags || undefined; // Clear empty strings
|
||||
stub.renderer = stub.renderer || undefined; // Clear empty strings
|
||||
stub = _.defaults(stub, DEFAULT_BREW_LOAD); // Fill in blank fields
|
||||
if(stub) {
|
||||
stub.tags = stub.tags || undefined; // Clear empty strings
|
||||
stub.renderer = stub.renderer || undefined; // Clear empty strings
|
||||
stub = _.defaults(stub, DEFAULT_BREW_LOAD); // Fill in blank fields
|
||||
}
|
||||
|
||||
req.brew = stub;
|
||||
req.brew = stub ?? {};
|
||||
next();
|
||||
};
|
||||
},
|
||||
@@ -108,7 +109,7 @@ If you believe you should have access to this brew, ask the file owner to invite
|
||||
excludePropsFromUpdate : (brew)=>{
|
||||
// Remove undesired properties
|
||||
const modified = _.clone(brew);
|
||||
const propsToExclude = ['_id', 'views', 'lastViewed', 'editId', 'shareId', 'googleId'];
|
||||
const propsToExclude = ['_id', 'views', 'lastViewed'];
|
||||
for (const prop of propsToExclude) {
|
||||
delete modified[prop];
|
||||
}
|
||||
@@ -188,17 +189,18 @@ If you believe you should have access to this brew, ask the file owner to invite
|
||||
res.status(200).send(saved);
|
||||
},
|
||||
updateBrew : async (req, res)=>{
|
||||
// Initialize brew from request and body, destructure query params, set a constant for the google id, and set the initial value for the after-save method
|
||||
// Initialize brew from request and body, destructure query params, and set the initial value for the after-save method
|
||||
const brewFromClient = api.excludePropsFromUpdate(req.body);
|
||||
if(req.brew.version && brewFromClient.version && req.brew.version > brewFromClient.version) {
|
||||
console.log(`Version mismatch on brew ${req.body.editId}`);
|
||||
// res.setHeader('Content-Type', 'application/json');
|
||||
// return res.status(409).send(JSON.stringify({ message: `The brew has been changed on a different device. Please save your changes elsewhere, refresh, and try again.` }));
|
||||
const brewFromServer = req.brew;
|
||||
if(brewFromServer.version && brewFromClient.version && brewFromServer.version > brewFromClient.version) {
|
||||
console.log(`Version mismatch on brew ${brewFromClient.editId}`);
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
return res.status(409).send(JSON.stringify({ message: `The brew has been changed on a different device. Please save your changes elsewhere, refresh, and try again.` }));
|
||||
}
|
||||
|
||||
let brew = _.assign(req.brew, brewFromClient);
|
||||
const { saveToGoogle, removeFromGoogle } = req.query;
|
||||
let brew = _.assign(brewFromServer, brewFromClient);
|
||||
const googleId = brew.googleId;
|
||||
const { saveToGoogle, removeFromGoogle } = req.query;
|
||||
let afterSave = async ()=>true;
|
||||
|
||||
brew.text = api.mergeBrewText(brew);
|
||||
|
||||
@@ -342,9 +342,6 @@ brew`);
|
||||
expect(result._id).toBeUndefined();
|
||||
expect(result.views).toBeUndefined();
|
||||
expect(result.lastViewed).toBeUndefined();
|
||||
expect(result.editId).toBeUndefined();
|
||||
expect(result.shareId).toBeUndefined();
|
||||
expect(result.googleId).toBeUndefined();
|
||||
});
|
||||
|
||||
it('excludeGoogleProps removes the correct keys', ()=>{
|
||||
|
||||
Reference in New Issue
Block a user