fix: no more duplicate error messges (#71)
* fix: Fix middlware order * fix: Remove console.log * feat: Uniq error meassages
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
"dotenv": "^4.0.0",
|
"dotenv": "^4.0.0",
|
||||||
"express": "~4.14.0",
|
"express": "~4.14.0",
|
||||||
"helmet": "^3.9.0",
|
"helmet": "^3.9.0",
|
||||||
|
"loadash": "^1.0.0",
|
||||||
"marked": "^0.3.6",
|
"marked": "^0.3.6",
|
||||||
"morgan": "~1.7.0",
|
"morgan": "~1.7.0",
|
||||||
"pug": "~2.0.0-beta6"
|
"pug": "~2.0.0-beta6"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const { createClient } = require('contentful')
|
|||||||
const { initClients, getSpace } = require('./../services/contentful')
|
const { initClients, getSpace } = require('./../services/contentful')
|
||||||
const { updateCookie } = require('../lib/cookies')
|
const { updateCookie } = require('../lib/cookies')
|
||||||
const { translate } = require('../i18n/i18n')
|
const { translate } = require('../i18n/i18n')
|
||||||
|
const { uniqWith, isEqual } = require('lodash')
|
||||||
const SETTINGS_NAME = 'theExampleAppSettings'
|
const SETTINGS_NAME = 'theExampleAppSettings'
|
||||||
|
|
||||||
async function renderSettings (response, opts) {
|
async function renderSettings (response, opts) {
|
||||||
@@ -58,7 +58,7 @@ module.exports.getSettings = async (request, response, next) => {
|
|||||||
*/
|
*/
|
||||||
module.exports.postSettings = async (request, response, next) => {
|
module.exports.postSettings = async (request, response, next) => {
|
||||||
const currentLocale = response.locals.currentLocale
|
const currentLocale = response.locals.currentLocale
|
||||||
const errorList = []
|
let errorList = []
|
||||||
const { spaceId, deliveryToken, previewToken, editorialFeatures } = request.body
|
const { spaceId, deliveryToken, previewToken, editorialFeatures } = request.body
|
||||||
const settings = {
|
const settings = {
|
||||||
spaceId,
|
spaceId,
|
||||||
@@ -143,7 +143,7 @@ module.exports.postSettings = async (request, response, next) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
errorList = uniqWith(errorList, isEqual)
|
||||||
// If no errors, then cache the new settings in the cookie
|
// If no errors, then cache the new settings in the cookie
|
||||||
if (!errorList.length) {
|
if (!errorList.length) {
|
||||||
// Store new settings
|
// Store new settings
|
||||||
|
|||||||
Reference in New Issue
Block a user