mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 02:16:03 +00:00
refactor
Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
parent
bc3cee4c54
commit
20aedc0e68
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const nodeSES = require('node-ses');
|
||||
const _ = require('lodash');
|
||||
const { removeUndefined } = require('strapi-utils');
|
||||
|
||||
module.exports = {
|
||||
init: (providerOptions = {}, settings = {}) => {
|
||||
@ -24,9 +24,7 @@ module.exports = {
|
||||
...rest,
|
||||
};
|
||||
|
||||
msg = _.pickBy(msg, value => typeof value !== 'undefined');
|
||||
|
||||
client.sendEmail(msg, function(err) {
|
||||
client.sendEmail(removeUndefined(msg), function(err) {
|
||||
if (err) {
|
||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||
} else {
|
||||
|
||||
@ -14,8 +14,8 @@
|
||||
},
|
||||
"main": "./lib",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.11",
|
||||
"node-ses": "^3.0.0"
|
||||
"node-ses": "^3.0.0",
|
||||
"strapi-utils": "^3.0.0-beta.20.3"
|
||||
},
|
||||
"author": {
|
||||
"email": "nikolay@tsenkov.net",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const mailgunFactory = require('mailgun-js');
|
||||
const _ = require('lodash');
|
||||
const { removeUndefined } = require('strapi-utils');
|
||||
|
||||
module.exports = {
|
||||
init: (providerOptions = {}, settings = {}) => {
|
||||
@ -27,9 +27,7 @@ module.exports = {
|
||||
...rest,
|
||||
};
|
||||
|
||||
msg = _.pickBy(msg, value => typeof value !== 'undefined');
|
||||
|
||||
mailgun.messages().send(msg, function(err) {
|
||||
mailgun.messages().send(removeUndefined(msg), function(err) {
|
||||
if (err) {
|
||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||
} else {
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
},
|
||||
"main": "./lib",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.11",
|
||||
"mailgun-js": "0.22.0"
|
||||
"mailgun-js": "0.22.0",
|
||||
"strapi-utils": "^3.0.0-beta.20.3"
|
||||
},
|
||||
"strapi": {
|
||||
"isProvider": true
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const sendgrid = require('@sendgrid/mail');
|
||||
const _ = require('lodash');
|
||||
const { removeUndefined } = require('strapi-utils');
|
||||
|
||||
module.exports = {
|
||||
init: (providerOptions = {}, settings = {}) => {
|
||||
@ -24,9 +24,7 @@ module.exports = {
|
||||
...rest,
|
||||
};
|
||||
|
||||
msg = _.pickBy(msg, value => typeof value !== 'undefined');
|
||||
|
||||
sendgrid.send(msg, function(err) {
|
||||
sendgrid.send(removeUndefined(msg), function(err) {
|
||||
if (err) {
|
||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||
} else {
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
"main": "./lib",
|
||||
"dependencies": {
|
||||
"@sendgrid/mail": "6.4.0",
|
||||
"lodash": "^4.17.11"
|
||||
"strapi-utils": "^3.0.0-beta.20.3"
|
||||
},
|
||||
"strapi": {
|
||||
"isProvider": true
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const sendmailFactory = require('sendmail');
|
||||
const _ = require('lodash');
|
||||
const { removeUndefined } = require('strapi-utils');
|
||||
|
||||
module.exports = {
|
||||
init: (providerOptions = {}, settings = {}) => {
|
||||
@ -26,9 +26,7 @@ module.exports = {
|
||||
...rest,
|
||||
};
|
||||
|
||||
msg = _.pickBy(msg, value => typeof value !== 'undefined');
|
||||
|
||||
sendmail(msg, err => {
|
||||
sendmail(removeUndefined(msg), err => {
|
||||
if (err) {
|
||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||
} else {
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
},
|
||||
"main": "./lib",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.11",
|
||||
"sendmail": "^1.6.1"
|
||||
"sendmail": "^1.6.1",
|
||||
"strapi-utils": "^3.0.0-beta.20.3"
|
||||
},
|
||||
"strapi": {
|
||||
"isProvider": true
|
||||
|
||||
@ -21,6 +21,7 @@ const {
|
||||
getCommonBeginning,
|
||||
escapeQuery,
|
||||
} = require('./stringFormatting');
|
||||
const { removeUndefined } = require('./objectFormatting');
|
||||
const { getConfigUrls } = require('./config');
|
||||
|
||||
module.exports = {
|
||||
@ -41,4 +42,5 @@ module.exports = {
|
||||
getCommonBeginning,
|
||||
getConfigUrls,
|
||||
escapeQuery,
|
||||
removeUndefined,
|
||||
};
|
||||
|
||||
9
packages/strapi-utils/lib/objectFormatting.js
Normal file
9
packages/strapi-utils/lib/objectFormatting.js
Normal file
@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
const removeUndefined = obj => _.pickBy(obj, value => typeof value !== 'undefined');
|
||||
|
||||
module.exports = {
|
||||
removeUndefined,
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user