mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 03:17:11 +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';
|
'use strict';
|
||||||
|
|
||||||
const nodeSES = require('node-ses');
|
const nodeSES = require('node-ses');
|
||||||
const _ = require('lodash');
|
const { removeUndefined } = require('strapi-utils');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
init: (providerOptions = {}, settings = {}) => {
|
init: (providerOptions = {}, settings = {}) => {
|
||||||
@ -24,9 +24,7 @@ module.exports = {
|
|||||||
...rest,
|
...rest,
|
||||||
};
|
};
|
||||||
|
|
||||||
msg = _.pickBy(msg, value => typeof value !== 'undefined');
|
client.sendEmail(removeUndefined(msg), function(err) {
|
||||||
|
|
||||||
client.sendEmail(msg, function(err) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -14,8 +14,8 @@
|
|||||||
},
|
},
|
||||||
"main": "./lib",
|
"main": "./lib",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lodash": "^4.17.11",
|
"node-ses": "^3.0.0",
|
||||||
"node-ses": "^3.0.0"
|
"strapi-utils": "^3.0.0-beta.20.3"
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"email": "nikolay@tsenkov.net",
|
"email": "nikolay@tsenkov.net",
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const mailgunFactory = require('mailgun-js');
|
const mailgunFactory = require('mailgun-js');
|
||||||
const _ = require('lodash');
|
const { removeUndefined } = require('strapi-utils');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
init: (providerOptions = {}, settings = {}) => {
|
init: (providerOptions = {}, settings = {}) => {
|
||||||
@ -27,9 +27,7 @@ module.exports = {
|
|||||||
...rest,
|
...rest,
|
||||||
};
|
};
|
||||||
|
|
||||||
msg = _.pickBy(msg, value => typeof value !== 'undefined');
|
mailgun.messages().send(removeUndefined(msg), function(err) {
|
||||||
|
|
||||||
mailgun.messages().send(msg, function(err) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -13,8 +13,8 @@
|
|||||||
},
|
},
|
||||||
"main": "./lib",
|
"main": "./lib",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lodash": "^4.17.11",
|
"mailgun-js": "0.22.0",
|
||||||
"mailgun-js": "0.22.0"
|
"strapi-utils": "^3.0.0-beta.20.3"
|
||||||
},
|
},
|
||||||
"strapi": {
|
"strapi": {
|
||||||
"isProvider": true
|
"isProvider": true
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const sendgrid = require('@sendgrid/mail');
|
const sendgrid = require('@sendgrid/mail');
|
||||||
const _ = require('lodash');
|
const { removeUndefined } = require('strapi-utils');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
init: (providerOptions = {}, settings = {}) => {
|
init: (providerOptions = {}, settings = {}) => {
|
||||||
@ -24,9 +24,7 @@ module.exports = {
|
|||||||
...rest,
|
...rest,
|
||||||
};
|
};
|
||||||
|
|
||||||
msg = _.pickBy(msg, value => typeof value !== 'undefined');
|
sendgrid.send(removeUndefined(msg), function(err) {
|
||||||
|
|
||||||
sendgrid.send(msg, function(err) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
"main": "./lib",
|
"main": "./lib",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sendgrid/mail": "6.4.0",
|
"@sendgrid/mail": "6.4.0",
|
||||||
"lodash": "^4.17.11"
|
"strapi-utils": "^3.0.0-beta.20.3"
|
||||||
},
|
},
|
||||||
"strapi": {
|
"strapi": {
|
||||||
"isProvider": true
|
"isProvider": true
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const sendmailFactory = require('sendmail');
|
const sendmailFactory = require('sendmail');
|
||||||
const _ = require('lodash');
|
const { removeUndefined } = require('strapi-utils');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
init: (providerOptions = {}, settings = {}) => {
|
init: (providerOptions = {}, settings = {}) => {
|
||||||
@ -26,9 +26,7 @@ module.exports = {
|
|||||||
...rest,
|
...rest,
|
||||||
};
|
};
|
||||||
|
|
||||||
msg = _.pickBy(msg, value => typeof value !== 'undefined');
|
sendmail(removeUndefined(msg), err => {
|
||||||
|
|
||||||
sendmail(msg, err => {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -12,8 +12,8 @@
|
|||||||
},
|
},
|
||||||
"main": "./lib",
|
"main": "./lib",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lodash": "^4.17.11",
|
"sendmail": "^1.6.1",
|
||||||
"sendmail": "^1.6.1"
|
"strapi-utils": "^3.0.0-beta.20.3"
|
||||||
},
|
},
|
||||||
"strapi": {
|
"strapi": {
|
||||||
"isProvider": true
|
"isProvider": true
|
||||||
|
|||||||
@ -21,6 +21,7 @@ const {
|
|||||||
getCommonBeginning,
|
getCommonBeginning,
|
||||||
escapeQuery,
|
escapeQuery,
|
||||||
} = require('./stringFormatting');
|
} = require('./stringFormatting');
|
||||||
|
const { removeUndefined } = require('./objectFormatting');
|
||||||
const { getConfigUrls } = require('./config');
|
const { getConfigUrls } = require('./config');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -41,4 +42,5 @@ module.exports = {
|
|||||||
getCommonBeginning,
|
getCommonBeginning,
|
||||||
getConfigUrls,
|
getConfigUrls,
|
||||||
escapeQuery,
|
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