@akemona-org/strapi 3.7.0 → 3.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/strapi.js +30 -28
- package/lib/commands/admin-reset.js +1 -1
- package/lib/commands/configurationDump.js +3 -3
- package/lib/commands/configurationRestore.js +4 -4
- package/lib/commands/console.js +1 -1
- package/lib/commands/generate.js +1 -0
- package/lib/commands/install.js +3 -3
- package/lib/commands/uninstall.js +2 -2
- package/lib/core/fs.js +2 -4
- package/lib/core/load-admin.js +2 -2
- package/lib/core/load-apis.js +1 -3
- package/lib/core/load-components.js +2 -2
- package/lib/core/load-extensions.js +4 -4
- package/lib/core/load-functions.js +2 -2
- package/lib/core/load-hooks.js +6 -6
- package/lib/core/load-middlewares.js +11 -8
- package/lib/core/load-modules.js +1 -1
- package/lib/core/load-plugins.js +2 -2
- package/lib/core/load-policies.js +3 -3
- package/lib/hooks/index.js +10 -16
- package/lib/load/check-reserved-filename.js +1 -1
- package/lib/load/filepath-to-prop-path.js +1 -1
- package/lib/load/package-path.js +1 -1
- package/lib/middlewares/boom/index.js +8 -11
- package/lib/middlewares/cors/index.js +4 -11
- package/lib/middlewares/cron/index.js +2 -2
- package/lib/middlewares/csp/index.js +2 -5
- package/lib/middlewares/favicon/index.js +2 -5
- package/lib/middlewares/gzip/index.js +1 -1
- package/lib/middlewares/hsts/index.js +2 -5
- package/lib/middlewares/index.js +7 -7
- package/lib/middlewares/ip/index.js +1 -1
- package/lib/middlewares/language/index.js +1 -1
- package/lib/middlewares/logger/index.js +2 -2
- package/lib/middlewares/p3p/index.js +2 -5
- package/lib/middlewares/parser/index.js +1 -1
- package/lib/middlewares/poweredBy/index.js +1 -1
- package/lib/middlewares/public/index.js +2 -2
- package/lib/middlewares/responseTime/index.js +1 -1
- package/lib/middlewares/responses/index.js +1 -1
- package/lib/middlewares/router/index.js +4 -4
- package/lib/middlewares/router/utils/composeEndpoint.js +1 -1
- package/lib/middlewares/session/index.js +3 -3
- package/lib/middlewares/xframe/index.js +2 -1
- package/lib/middlewares/xss/index.js +2 -1
- package/lib/services/core-store.js +23 -16
- package/lib/services/metrics/index.js +5 -9
- package/lib/services/metrics/is-truthy.js +1 -1
- package/lib/services/metrics/sender.js +1 -1
- package/lib/services/metrics/stringify-deep.js +1 -1
- package/lib/services/utils/upload-files.js +2 -2
- package/lib/services/webhook-runner.js +7 -11
- package/lib/services/webhook-store.js +3 -3
- package/lib/utils/addSlash.js +1 -1
- package/lib/utils/ee.js +1 -1
- package/lib/utils/get-prefixed-dependencies.js +2 -2
- package/lib/utils/run-checks.js +3 -3
- package/lib/utils/url-from-segments.js +1 -2
- package/package.json +12 -12
|
@@ -14,25 +14,18 @@ const defaults = {
|
|
|
14
14
|
keepHeadersOnError: false,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
module.exports = strapi => {
|
|
17
|
+
module.exports = (strapi) => {
|
|
18
18
|
return {
|
|
19
19
|
/**
|
|
20
20
|
* Initialize the hook
|
|
21
21
|
*/
|
|
22
22
|
initialize() {
|
|
23
|
-
const {
|
|
24
|
-
|
|
25
|
-
expose,
|
|
26
|
-
maxAge,
|
|
27
|
-
credentials,
|
|
28
|
-
methods,
|
|
29
|
-
headers,
|
|
30
|
-
keepHeadersOnError,
|
|
31
|
-
} = Object.assign({}, defaults, strapi.config.get('middleware.settings.cors'));
|
|
23
|
+
const { origin, expose, maxAge, credentials, methods, headers, keepHeadersOnError } =
|
|
24
|
+
Object.assign({}, defaults, strapi.config.get('middleware.settings.cors'));
|
|
32
25
|
|
|
33
26
|
strapi.app.use(
|
|
34
27
|
cors({
|
|
35
|
-
origin: async function(ctx) {
|
|
28
|
+
origin: async function (ctx) {
|
|
36
29
|
let originList;
|
|
37
30
|
|
|
38
31
|
if (typeof origin === 'function') {
|
|
@@ -12,7 +12,7 @@ const cron = require('node-schedule');
|
|
|
12
12
|
* CRON hook
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
module.exports = strapi => {
|
|
15
|
+
module.exports = (strapi) => {
|
|
16
16
|
return {
|
|
17
17
|
/**
|
|
18
18
|
* Initialize the hook
|
|
@@ -20,7 +20,7 @@ module.exports = strapi => {
|
|
|
20
20
|
|
|
21
21
|
initialize() {
|
|
22
22
|
if (strapi.config.get('server.cron.enabled', false) === true) {
|
|
23
|
-
_.forEach(_.keys(strapi.config.get('functions.cron', {})), taskExpression => {
|
|
23
|
+
_.forEach(_.keys(strapi.config.get('functions.cron', {})), (taskExpression) => {
|
|
24
24
|
const taskValue = strapi.config.functions.cron[taskExpression];
|
|
25
25
|
|
|
26
26
|
if (_.isFunction(taskValue)) {
|
|
@@ -6,7 +6,7 @@ const { csp } = require('koa-lusca');
|
|
|
6
6
|
* CSP hook
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
module.exports = strapi => {
|
|
9
|
+
module.exports = (strapi) => {
|
|
10
10
|
return {
|
|
11
11
|
/**
|
|
12
12
|
* Initialize the hook
|
|
@@ -16,10 +16,7 @@ module.exports = strapi => {
|
|
|
16
16
|
strapi.app.use(async (ctx, next) => {
|
|
17
17
|
if (ctx.request.admin) return await next();
|
|
18
18
|
|
|
19
|
-
return await convert(csp(strapi.config.middleware.settings.csp))(
|
|
20
|
-
ctx,
|
|
21
|
-
next
|
|
22
|
-
);
|
|
19
|
+
return await convert(csp(strapi.config.middleware.settings.csp))(ctx, next);
|
|
23
20
|
});
|
|
24
21
|
},
|
|
25
22
|
};
|
|
@@ -12,7 +12,7 @@ const favicon = require('koa-favicon');
|
|
|
12
12
|
* Favicon hook
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
module.exports = strapi => {
|
|
15
|
+
module.exports = (strapi) => {
|
|
16
16
|
return {
|
|
17
17
|
/**
|
|
18
18
|
* Initialize the hook
|
|
@@ -20,10 +20,7 @@ module.exports = strapi => {
|
|
|
20
20
|
|
|
21
21
|
initialize() {
|
|
22
22
|
const { dir } = strapi;
|
|
23
|
-
const {
|
|
24
|
-
maxAge,
|
|
25
|
-
path: faviconPath,
|
|
26
|
-
} = strapi.config.middleware.settings.favicon;
|
|
23
|
+
const { maxAge, path: faviconPath } = strapi.config.middleware.settings.favicon;
|
|
27
24
|
|
|
28
25
|
strapi.app.use(
|
|
29
26
|
favicon(resolve(dir, faviconPath), {
|
|
@@ -10,7 +10,7 @@ const { hsts } = require('koa-lusca');
|
|
|
10
10
|
* HSTS hook
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
module.exports = strapi => {
|
|
13
|
+
module.exports = (strapi) => {
|
|
14
14
|
return {
|
|
15
15
|
/**
|
|
16
16
|
* Initialize the hook
|
|
@@ -20,10 +20,7 @@ module.exports = strapi => {
|
|
|
20
20
|
strapi.app.use(async (ctx, next) => {
|
|
21
21
|
if (ctx.request.admin) return next();
|
|
22
22
|
|
|
23
|
-
return await convert(hsts(strapi.config.middleware.settings.hsts))(
|
|
24
|
-
ctx,
|
|
25
|
-
next
|
|
26
|
-
);
|
|
23
|
+
return await convert(hsts(strapi.config.middleware.settings.hsts))(ctx, next);
|
|
27
24
|
});
|
|
28
25
|
},
|
|
29
26
|
};
|
package/lib/middlewares/index.js
CHANGED
|
@@ -15,17 +15,17 @@ const requiredMiddlewares = [
|
|
|
15
15
|
'favicon',
|
|
16
16
|
];
|
|
17
17
|
|
|
18
|
-
module.exports = async function() {
|
|
18
|
+
module.exports = async function () {
|
|
19
19
|
/** Utils */
|
|
20
20
|
const middlewareConfig = this.config.middleware;
|
|
21
21
|
|
|
22
22
|
// check if a middleware exists
|
|
23
|
-
const middlewareExists = key => {
|
|
23
|
+
const middlewareExists = (key) => {
|
|
24
24
|
return !isUndefined(this.middleware[key]);
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
// check if a middleware is enabled
|
|
28
|
-
const middlewareEnabled = key => {
|
|
28
|
+
const middlewareEnabled = (key) => {
|
|
29
29
|
return (
|
|
30
30
|
requiredMiddlewares.includes(key) ||
|
|
31
31
|
get(middlewareConfig, ['settings', key, 'enabled'], false) === true
|
|
@@ -36,7 +36,7 @@ module.exports = async function() {
|
|
|
36
36
|
const enabledMiddlewares = Object.keys(this.middleware).filter(middlewareEnabled);
|
|
37
37
|
|
|
38
38
|
// Method to initialize middlewares and emit an event.
|
|
39
|
-
const initialize = middlewareKey => {
|
|
39
|
+
const initialize = (middlewareKey) => {
|
|
40
40
|
if (this.middleware[middlewareKey].loaded === true) return;
|
|
41
41
|
|
|
42
42
|
const module = this.middleware[middlewareKey].load;
|
|
@@ -56,7 +56,7 @@ module.exports = async function() {
|
|
|
56
56
|
this.middleware[middlewareKey].loaded = true;
|
|
57
57
|
resolve();
|
|
58
58
|
})
|
|
59
|
-
.catch(err => {
|
|
59
|
+
.catch((err) => {
|
|
60
60
|
clearTimeout(timeout);
|
|
61
61
|
|
|
62
62
|
if (err) {
|
|
@@ -72,7 +72,7 @@ module.exports = async function() {
|
|
|
72
72
|
|
|
73
73
|
// Run beforeInitialize of every middleware
|
|
74
74
|
await Promise.all(
|
|
75
|
-
enabledMiddlewares.map(key => {
|
|
75
|
+
enabledMiddlewares.map((key) => {
|
|
76
76
|
const { beforeInitialize } = this.middleware[key].load;
|
|
77
77
|
if (typeof beforeInitialize === 'function') {
|
|
78
78
|
return beforeInitialize();
|
|
@@ -81,7 +81,7 @@ module.exports = async function() {
|
|
|
81
81
|
);
|
|
82
82
|
|
|
83
83
|
// run the initialization of an array of middlewares sequentially
|
|
84
|
-
const initMiddlewaresSeq = async middlewareArr => {
|
|
84
|
+
const initMiddlewaresSeq = async (middlewareArr) => {
|
|
85
85
|
for (let key of uniq(middlewareArr)) {
|
|
86
86
|
await initialize(key);
|
|
87
87
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const chalk = require('chalk');
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
|
|
5
|
-
const codeToColor = code => {
|
|
5
|
+
const codeToColor = (code) => {
|
|
6
6
|
return code >= 500
|
|
7
7
|
? chalk.red(code)
|
|
8
8
|
: code >= 400
|
|
@@ -18,7 +18,7 @@ const codeToColor = code => {
|
|
|
18
18
|
* Logger hook
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
module.exports = strapi => {
|
|
21
|
+
module.exports = (strapi) => {
|
|
22
22
|
return {
|
|
23
23
|
/**
|
|
24
24
|
* Initialize the hook
|
|
@@ -9,7 +9,7 @@ const { p3p } = require('koa-lusca');
|
|
|
9
9
|
* P3P hook
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
module.exports = strapi => {
|
|
12
|
+
module.exports = (strapi) => {
|
|
13
13
|
return {
|
|
14
14
|
/**
|
|
15
15
|
* Initialize the hook
|
|
@@ -19,10 +19,7 @@ module.exports = strapi => {
|
|
|
19
19
|
strapi.app.use(async (ctx, next) => {
|
|
20
20
|
if (ctx.request.admin) return next();
|
|
21
21
|
|
|
22
|
-
return await convert(p3p(strapi.config.middleware.settings.p3p))(
|
|
23
|
-
ctx,
|
|
24
|
-
next
|
|
25
|
-
);
|
|
22
|
+
return await convert(p3p(strapi.config.middleware.settings.p3p))(ctx, next);
|
|
26
23
|
});
|
|
27
24
|
},
|
|
28
25
|
};
|
|
@@ -17,7 +17,7 @@ const serveStatic = require('./serve-static');
|
|
|
17
17
|
* Public assets hook
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
module.exports = strapi => {
|
|
20
|
+
module.exports = (strapi) => {
|
|
21
21
|
return {
|
|
22
22
|
/**
|
|
23
23
|
* Initialize the hook
|
|
@@ -81,7 +81,7 @@ module.exports = strapi => {
|
|
|
81
81
|
if (!strapi.config.serveAdminPanel) return;
|
|
82
82
|
|
|
83
83
|
const buildDir = path.resolve(strapi.dir, 'build');
|
|
84
|
-
const serveAdmin = ctx => {
|
|
84
|
+
const serveAdmin = (ctx) => {
|
|
85
85
|
ctx.type = 'html';
|
|
86
86
|
ctx.body = fs.createReadStream(path.join(buildDir + '/index.html'));
|
|
87
87
|
};
|
|
@@ -12,7 +12,7 @@ const createEndpointComposer = require('./utils/composeEndpoint');
|
|
|
12
12
|
* Router hook
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
module.exports = strapi => {
|
|
15
|
+
module.exports = (strapi) => {
|
|
16
16
|
const composeEndpoint = createEndpointComposer(strapi);
|
|
17
17
|
|
|
18
18
|
return {
|
|
@@ -21,7 +21,7 @@ module.exports = strapi => {
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
initialize() {
|
|
24
|
-
_.forEach(strapi.config.routes, value => {
|
|
24
|
+
_.forEach(strapi.config.routes, (value) => {
|
|
25
25
|
composeEndpoint(value, { router: strapi.router });
|
|
26
26
|
});
|
|
27
27
|
|
|
@@ -32,7 +32,7 @@ module.exports = strapi => {
|
|
|
32
32
|
prefix: '/admin',
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
_.get(strapi.admin, 'config.routes', []).forEach(route => {
|
|
35
|
+
_.get(strapi.admin, 'config.routes', []).forEach((route) => {
|
|
36
36
|
composeEndpoint(route, { plugin: 'admin', router });
|
|
37
37
|
});
|
|
38
38
|
|
|
@@ -47,7 +47,7 @@ module.exports = strapi => {
|
|
|
47
47
|
prefix: `/${pluginName}`,
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
(plugin.config.routes || []).forEach(route => {
|
|
50
|
+
(plugin.config.routes || []).forEach((route) => {
|
|
51
51
|
const hasPrefix = _.has(route.config, 'prefix');
|
|
52
52
|
composeEndpoint(route, {
|
|
53
53
|
plugin: pluginName,
|
|
@@ -4,7 +4,7 @@ const _ = require('lodash');
|
|
|
4
4
|
const compose = require('koa-compose');
|
|
5
5
|
const createRouteChecker = require('./routerChecker');
|
|
6
6
|
|
|
7
|
-
module.exports = strapi => {
|
|
7
|
+
module.exports = (strapi) => {
|
|
8
8
|
const routerChecker = createRouteChecker(strapi);
|
|
9
9
|
|
|
10
10
|
return (value, { plugin, router }) => {
|
|
@@ -7,12 +7,12 @@ const session = require('koa-session');
|
|
|
7
7
|
/**
|
|
8
8
|
* Session middleware
|
|
9
9
|
*/
|
|
10
|
-
module.exports = strapi => {
|
|
11
|
-
const requireStore = store => {
|
|
10
|
+
module.exports = (strapi) => {
|
|
11
|
+
const requireStore = (store) => {
|
|
12
12
|
return require(path.resolve(strapi.config.appPath, 'node_modules', 'koa-' + store));
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
const defineStore = session => {
|
|
15
|
+
const defineStore = (session) => {
|
|
16
16
|
if (_.isEmpty(_.get(session, 'client'))) {
|
|
17
17
|
return strapi.log.error(
|
|
18
18
|
'(middleware:session) please provide a valid client to store session'
|
|
@@ -7,13 +7,14 @@ const { xframe } = require('koa-lusca');
|
|
|
7
7
|
* CRON hook
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
module.exports = strapi => {
|
|
10
|
+
module.exports = (strapi) => {
|
|
11
11
|
return {
|
|
12
12
|
/**
|
|
13
13
|
* Initialize the hook
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
initialize() {
|
|
17
|
+
// eslint-disable-next-line import/extensions
|
|
17
18
|
const defaults = require('./defaults.json');
|
|
18
19
|
|
|
19
20
|
strapi.app.use(async (ctx, next) => {
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
const convert = require('koa-convert');
|
|
4
4
|
const { xssProtection } = require('koa-lusca');
|
|
5
5
|
|
|
6
|
-
module.exports = strapi => {
|
|
6
|
+
module.exports = (strapi) => {
|
|
7
7
|
return {
|
|
8
8
|
initialize() {
|
|
9
|
+
// eslint-disable-next-line import/extensions
|
|
9
10
|
const defaults = require('./defaults.json');
|
|
10
11
|
|
|
11
12
|
strapi.app.use(async (ctx, next) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const coreStoreModel = config => ({
|
|
3
|
+
const coreStoreModel = (config) => ({
|
|
4
4
|
connection: config.get('database.defaultConnection'),
|
|
5
5
|
uid: 'strapi::core-store',
|
|
6
6
|
info: {
|
|
@@ -39,11 +39,13 @@ const coreStoreModel = config => ({
|
|
|
39
39
|
const createCoreStore = ({ environment: defaultEnv, db }) => {
|
|
40
40
|
return (source = {}) => {
|
|
41
41
|
async function get(params = {}) {
|
|
42
|
-
const {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const {
|
|
43
|
+
key,
|
|
44
|
+
environment = defaultEnv,
|
|
45
|
+
type = 'core',
|
|
46
|
+
name = '',
|
|
47
|
+
tag = '',
|
|
48
|
+
} = Object.assign({}, source, params);
|
|
47
49
|
|
|
48
50
|
const prefix = `${type}${name ? `_${name}` : ''}`;
|
|
49
51
|
|
|
@@ -78,11 +80,14 @@ const createCoreStore = ({ environment: defaultEnv, db }) => {
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
async function set(params = {}) {
|
|
81
|
-
const {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
const {
|
|
84
|
+
key,
|
|
85
|
+
value,
|
|
86
|
+
environment = defaultEnv,
|
|
87
|
+
type,
|
|
88
|
+
name,
|
|
89
|
+
tag = '',
|
|
90
|
+
} = Object.assign({}, source, params);
|
|
86
91
|
|
|
87
92
|
const prefix = `${type}${name ? `_${name}` : ''}`;
|
|
88
93
|
|
|
@@ -113,11 +118,13 @@ const createCoreStore = ({ environment: defaultEnv, db }) => {
|
|
|
113
118
|
}
|
|
114
119
|
|
|
115
120
|
async function deleteFn(params = {}) {
|
|
116
|
-
const {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
const {
|
|
122
|
+
key,
|
|
123
|
+
environment = defaultEnv,
|
|
124
|
+
type,
|
|
125
|
+
name,
|
|
126
|
+
tag = '',
|
|
127
|
+
} = Object.assign({}, source, params);
|
|
121
128
|
|
|
122
129
|
const prefix = `${type}${name ? `_${name}` : ''}`;
|
|
123
130
|
|
|
@@ -22,7 +22,7 @@ const LIMITED_EVENTS = [
|
|
|
22
22
|
'didEnableResponsiveDimensions',
|
|
23
23
|
];
|
|
24
24
|
|
|
25
|
-
const createTelemetryInstance = strapi => {
|
|
25
|
+
const createTelemetryInstance = (strapi) => {
|
|
26
26
|
const { uuid } = strapi.config;
|
|
27
27
|
const isDisabled = !uuid || isTruthy(process.env.STRAPI_TELEMETRY_DISABLED);
|
|
28
28
|
|
|
@@ -68,7 +68,7 @@ const createTelemetryInstance = strapi => {
|
|
|
68
68
|
return {
|
|
69
69
|
destroy() {
|
|
70
70
|
// clear open handles
|
|
71
|
-
crons.forEach(cron => cron.cancel());
|
|
71
|
+
crons.forEach((cron) => cron.cancel());
|
|
72
72
|
},
|
|
73
73
|
async send(event, payload) {
|
|
74
74
|
if (isDisabled) return true;
|
|
@@ -77,15 +77,11 @@ const createTelemetryInstance = strapi => {
|
|
|
77
77
|
};
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
const hash = str =>
|
|
81
|
-
crypto
|
|
82
|
-
.createHash('sha256')
|
|
83
|
-
.update(str)
|
|
84
|
-
.digest('hex');
|
|
80
|
+
const hash = (str) => crypto.createHash('sha256').update(str).digest('hex');
|
|
85
81
|
|
|
86
|
-
const hashProject = strapi => hash(`${strapi.config.info.name}${strapi.config.info.description}`);
|
|
82
|
+
const hashProject = (strapi) => hash(`${strapi.config.info.name}${strapi.config.info.description}`);
|
|
87
83
|
|
|
88
|
-
const hashDep = strapi => {
|
|
84
|
+
const hashDep = (strapi) => {
|
|
89
85
|
const depStr = JSON.stringify(strapi.config.info.dependencies);
|
|
90
86
|
const readmePath = path.join(strapi.dir, 'README.md');
|
|
91
87
|
|
|
@@ -31,7 +31,7 @@ const addPackageJsonStrapiMetadata = (metadata, strapi) => {
|
|
|
31
31
|
* @param {Object} strapi strapi app
|
|
32
32
|
* @returns {Function} (event, payload) -> Promise{boolean}
|
|
33
33
|
*/
|
|
34
|
-
module.exports = strapi => {
|
|
34
|
+
module.exports = (strapi) => {
|
|
35
35
|
const { uuid } = strapi.config;
|
|
36
36
|
const deviceId = machineIdSync();
|
|
37
37
|
const isEE = strapi.EE === true && ee.isEE === true;
|
|
@@ -7,7 +7,7 @@ const { map, mapValues, isObject, isArray, toString } = require('lodash/fp');
|
|
|
7
7
|
* @param {object} obj
|
|
8
8
|
* @returns {object}
|
|
9
9
|
*/
|
|
10
|
-
const stringifyDeep = value => {
|
|
10
|
+
const stringifyDeep = (value) => {
|
|
11
11
|
if (isArray(value)) {
|
|
12
12
|
return map(stringifyDeep, value);
|
|
13
13
|
}
|
|
@@ -9,7 +9,7 @@ module.exports = async (entry, files, { model, source }) => {
|
|
|
9
9
|
|
|
10
10
|
const uploadService = strapi.plugins.upload.services.upload;
|
|
11
11
|
|
|
12
|
-
const findModelFromUploadPath = path => {
|
|
12
|
+
const findModelFromUploadPath = (path) => {
|
|
13
13
|
if (path.length === 0) return { model, source };
|
|
14
14
|
|
|
15
15
|
let currentPath = [];
|
|
@@ -66,5 +66,5 @@ module.exports = async (entry, files, { model, source }) => {
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
await Promise.all(Object.keys(files).map(key => doUpload(key, files[key])));
|
|
69
|
+
await Promise.all(Object.keys(files).map((key) => doUpload(key, files[key])));
|
|
70
70
|
};
|
|
@@ -51,7 +51,7 @@ class WebhookRunner {
|
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const listen = info => {
|
|
54
|
+
const listen = (info) => {
|
|
55
55
|
this.queue.enqueue({ event, info });
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -62,12 +62,10 @@ class WebhookRunner {
|
|
|
62
62
|
async executeListener({ event, info }) {
|
|
63
63
|
debug(`Executing webhook for event '${event}'`);
|
|
64
64
|
const webhooks = this.webhooksMap.get(event) || [];
|
|
65
|
-
const activeWebhooks = webhooks.filter(
|
|
66
|
-
webhook => webhook.isEnabled === true
|
|
67
|
-
);
|
|
65
|
+
const activeWebhooks = webhooks.filter((webhook) => webhook.isEnabled === true);
|
|
68
66
|
|
|
69
67
|
for (const webhook of activeWebhooks) {
|
|
70
|
-
await this.run(webhook, event, info).catch(error => {
|
|
68
|
+
await this.run(webhook, event, info).catch((error) => {
|
|
71
69
|
this.logger.error('Error running webhook');
|
|
72
70
|
this.logger.error(error);
|
|
73
71
|
});
|
|
@@ -92,7 +90,7 @@ class WebhookRunner {
|
|
|
92
90
|
},
|
|
93
91
|
timeout: 10000,
|
|
94
92
|
})
|
|
95
|
-
.then(async res => {
|
|
93
|
+
.then(async (res) => {
|
|
96
94
|
if (res.ok) {
|
|
97
95
|
return {
|
|
98
96
|
statusCode: res.status,
|
|
@@ -104,7 +102,7 @@ class WebhookRunner {
|
|
|
104
102
|
message: await res.text(),
|
|
105
103
|
};
|
|
106
104
|
})
|
|
107
|
-
.catch(err => {
|
|
105
|
+
.catch((err) => {
|
|
108
106
|
return {
|
|
109
107
|
statusCode: 500,
|
|
110
108
|
message: err.message,
|
|
@@ -116,7 +114,7 @@ class WebhookRunner {
|
|
|
116
114
|
debug(`Registering webhook '${webhook.id}'`);
|
|
117
115
|
const { events } = webhook;
|
|
118
116
|
|
|
119
|
-
events.forEach(event => {
|
|
117
|
+
events.forEach((event) => {
|
|
120
118
|
if (this.webhooksMap.has(event)) {
|
|
121
119
|
this.webhooksMap.get(event).push(webhook);
|
|
122
120
|
} else {
|
|
@@ -136,9 +134,7 @@ class WebhookRunner {
|
|
|
136
134
|
debug(`Unregistering webhook '${webhook.id}'`);
|
|
137
135
|
|
|
138
136
|
this.webhooksMap.forEach((webhooks, event) => {
|
|
139
|
-
const filteredWebhooks = webhooks.filter(
|
|
140
|
-
value => value.id !== webhook.id
|
|
141
|
-
);
|
|
137
|
+
const filteredWebhooks = webhooks.filter((value) => value.id !== webhook.id);
|
|
142
138
|
|
|
143
139
|
// Cleanup hanging listeners
|
|
144
140
|
if (filteredWebhooks.length === 0) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
-
const webhookModel = config => ({
|
|
6
|
+
const webhookModel = (config) => ({
|
|
7
7
|
connection: config.get('database.defaultConnection'),
|
|
8
8
|
uid: 'strapi::webhooks',
|
|
9
9
|
globalId: 'StrapiWebhooks',
|
|
@@ -39,7 +39,7 @@ const webhookModel = config => ({
|
|
|
39
39
|
},
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
const toDBObject = data => {
|
|
42
|
+
const toDBObject = (data) => {
|
|
43
43
|
return {
|
|
44
44
|
name: data.name,
|
|
45
45
|
url: data.url,
|
|
@@ -49,7 +49,7 @@ const toDBObject = data => {
|
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
const fromDBObject = row => {
|
|
52
|
+
const fromDBObject = (row) => {
|
|
53
53
|
return {
|
|
54
54
|
id: row.id,
|
|
55
55
|
name: row.name,
|
package/lib/utils/addSlash.js
CHANGED
package/lib/utils/ee.js
CHANGED
|
@@ -114,7 +114,7 @@ Object.defineProperty(module.exports, 'features', {
|
|
|
114
114
|
enumerable: false,
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
const mustHaveKey = key => {
|
|
117
|
+
const mustHaveKey = (key) => {
|
|
118
118
|
if (!_.has(internals, key)) {
|
|
119
119
|
const err = new Error('Tampering with license');
|
|
120
120
|
err.stack = null;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
module.exports = (prefix, pkgJSON) => {
|
|
4
4
|
return Object.keys(pkgJSON.dependencies)
|
|
5
|
-
.filter(d => d.startsWith(prefix) && d.length > prefix.length)
|
|
6
|
-
.map(pkgName => pkgName.substring(prefix.length + 1));
|
|
5
|
+
.filter((d) => d.startsWith(prefix) && d.length > prefix.length)
|
|
6
|
+
.map((pkgName) => pkgName.substring(prefix.length + 1));
|
|
7
7
|
};
|