@strapi/strapi 4.3.3 → 4.3.6
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/README.md +1 -1
- package/bin/strapi.js +29 -26
- package/lib/Strapi.js +9 -9
- package/lib/commands/admin-create.js +2 -5
- package/lib/commands/admin-reset.js +1 -1
- package/lib/commands/build.js +1 -1
- package/lib/commands/builders/admin.js +1 -1
- package/lib/commands/builders/typescript.js +2 -2
- package/lib/commands/configurationDump.js +3 -3
- package/lib/commands/configurationRestore.js +5 -4
- package/lib/commands/console.js +1 -1
- package/lib/commands/content-types/list.js +2 -2
- package/lib/commands/controllers/list.js +2 -2
- package/lib/commands/develop.js +16 -10
- package/lib/commands/hooks/list.js +2 -2
- package/lib/commands/install.js +4 -4
- package/lib/commands/middlewares/list.js +2 -2
- package/lib/commands/new.js +1 -1
- package/lib/commands/opt-in-telemetry.js +12 -13
- package/lib/commands/opt-out-telemetry.js +3 -3
- package/lib/commands/policies/list.js +2 -2
- package/lib/commands/routes/list.js +3 -3
- package/lib/commands/services/list.js +2 -2
- package/lib/commands/start.js +1 -0
- package/lib/commands/ts/generate-types.js +1 -1
- package/lib/commands/uninstall.js +4 -4
- package/lib/commands/watchAdmin.js +1 -1
- package/lib/compile.js +1 -1
- package/lib/container.js +1 -1
- package/lib/core/app-configuration/config-loader.js +2 -2
- package/lib/core/app-configuration/load-config-file.js +3 -3
- package/lib/core/bootstrap.js +1 -1
- package/lib/core/domain/component/validator.js +3 -9
- package/lib/core/domain/content-type/index.js +2 -2
- package/lib/core/domain/content-type/validator.js +9 -23
- package/lib/core/domain/module/index.js +1 -1
- package/lib/core/domain/module/validation.js +3 -4
- package/lib/core/loaders/admin.js +1 -1
- package/lib/core/loaders/apis.js +22 -30
- package/lib/core/loaders/components.js +2 -2
- package/lib/core/loaders/middlewares.js +1 -1
- package/lib/core/loaders/plugins/get-enabled-plugins.js +7 -7
- package/lib/core/loaders/plugins/index.js +7 -8
- package/lib/core/loaders/sanitizers.js +1 -1
- package/lib/core/loaders/src-index.js +2 -2
- package/lib/core/registries/apis.js +1 -1
- package/lib/core/registries/config.js +1 -1
- package/lib/core/registries/content-types.js +1 -1
- package/lib/core/registries/modules.js +1 -1
- package/lib/core/registries/plugins.js +1 -1
- package/lib/core/registries/services.js +1 -1
- package/lib/core/utils.js +3 -6
- package/lib/core-api/controller/transform.js +4 -4
- package/lib/core-api/service/collection-type.js +1 -1
- package/lib/core-api/service/index.d.ts +6 -3
- package/lib/core-api/service/pagination.js +5 -5
- package/lib/factories.js +5 -5
- package/lib/load/filepath-to-prop-path.js +2 -2
- package/lib/load/load-files.js +1 -1
- package/lib/load/package-path.js +1 -1
- package/lib/middlewares/body.js +10 -3
- package/lib/middlewares/compression.js +1 -1
- package/lib/middlewares/cors.js +3 -10
- package/lib/middlewares/ip.js +1 -1
- package/lib/middlewares/logger.js +4 -1
- package/lib/middlewares/powered-by.js +1 -1
- package/lib/middlewares/query.js +8 -2
- package/lib/middlewares/response-time.js +1 -1
- package/lib/middlewares/responses.js +1 -1
- package/lib/middlewares/security.js +22 -16
- package/lib/middlewares/session.js +2 -2
- package/lib/migrations/draft-publish.js +1 -5
- package/lib/services/auth/index.js +1 -3
- package/lib/services/core-store.js +4 -4
- package/lib/services/entity-service/components.js +12 -18
- package/lib/services/entity-service/index.js +65 -51
- package/lib/services/entity-validator/index.js +134 -127
- package/lib/services/entity-validator/validators.js +18 -15
- package/lib/services/errors.js +6 -10
- package/lib/services/event-hub.js +1 -0
- package/lib/services/fs.js +1 -1
- package/lib/services/metrics/index.js +6 -9
- package/lib/services/metrics/is-truthy.js +1 -1
- package/lib/services/metrics/sender.js +4 -4
- package/lib/services/metrics/stringify-deep.js +1 -1
- package/lib/services/server/admin-api.js +1 -1
- package/lib/services/server/compose-endpoint.js +7 -7
- package/lib/services/server/content-api.js +1 -1
- package/lib/services/server/http-server.js +9 -9
- package/lib/services/server/index.js +4 -4
- package/lib/services/server/koa.js +9 -12
- package/lib/services/server/middleware.js +1 -1
- package/lib/services/server/policy.js +1 -1
- package/lib/services/server/register-middlewares.js +6 -8
- package/lib/services/server/register-routes.js +11 -11
- package/lib/services/server/routing.js +11 -26
- package/lib/services/utils/upload-files.js +3 -3
- package/lib/services/webhook-runner.js +8 -7
- package/lib/services/webhook-store.js +3 -2
- package/lib/services/worker-queue.js +1 -0
- package/lib/types/core/strapi/index.d.ts +4 -3
- package/lib/types/factories.d.ts +3 -3
- package/lib/utils/addSlash.js +3 -3
- package/lib/utils/ee.js +1 -1
- package/lib/utils/import-default.js +1 -1
- package/lib/utils/open-browser.js +1 -1
- package/lib/utils/run-checks.js +4 -4
- package/lib/utils/signals.js +2 -2
- package/lib/utils/startup-logger.js +2 -2
- package/lib/utils/success.js +1 -1
- package/lib/utils/update-notifier/index.js +4 -4
- package/package.json +14 -14
|
@@ -10,7 +10,7 @@ const registerAllRoutes = require('./register-routes');
|
|
|
10
10
|
const registerApplicationMiddlewares = require('./register-middlewares');
|
|
11
11
|
const createKoaApp = require('./koa');
|
|
12
12
|
|
|
13
|
-
const healthCheck = async ctx => {
|
|
13
|
+
const healthCheck = async (ctx) => {
|
|
14
14
|
ctx.set('strapi', 'You are so French!');
|
|
15
15
|
ctx.status = 204;
|
|
16
16
|
};
|
|
@@ -27,7 +27,7 @@ const healthCheck = async ctx => {
|
|
|
27
27
|
* @param {Strapi} strapi
|
|
28
28
|
* @returns {Server}
|
|
29
29
|
*/
|
|
30
|
-
const createServer = strapi => {
|
|
30
|
+
const createServer = (strapi) => {
|
|
31
31
|
const app = createKoaApp({
|
|
32
32
|
proxy: strapi.config.get('server.proxy'),
|
|
33
33
|
keys: strapi.config.get('server.app.keys'),
|
|
@@ -83,7 +83,7 @@ const createServer = strapi => {
|
|
|
83
83
|
mount() {
|
|
84
84
|
state.mounted = true;
|
|
85
85
|
|
|
86
|
-
Object.values(apis).forEach(api => api.mount(router));
|
|
86
|
+
Object.values(apis).forEach((api) => api.mount(router));
|
|
87
87
|
app.use(router.routes()).use(router.allowedMethods());
|
|
88
88
|
|
|
89
89
|
return this;
|
|
@@ -104,7 +104,7 @@ const createServer = strapi => {
|
|
|
104
104
|
listRoutes() {
|
|
105
105
|
const allRoutes = [...router.stack];
|
|
106
106
|
|
|
107
|
-
Object.values(apis).forEach(api => {
|
|
107
|
+
Object.values(apis).forEach((api) => {
|
|
108
108
|
allRoutes.push(...api.listRoutes());
|
|
109
109
|
});
|
|
110
110
|
|
|
@@ -4,19 +4,19 @@ const { isNil, camelCase } = require('lodash/fp');
|
|
|
4
4
|
const Koa = require('koa');
|
|
5
5
|
const createError = require('http-errors');
|
|
6
6
|
const delegate = require('delegates');
|
|
7
|
-
|
|
7
|
+
const statuses = require('statuses');
|
|
8
8
|
const { formatHttpError } = require('../errors');
|
|
9
9
|
|
|
10
|
-
const addCustomMethods = app => {
|
|
10
|
+
const addCustomMethods = (app) => {
|
|
11
11
|
const delegator = delegate(app.context, 'response');
|
|
12
12
|
|
|
13
13
|
/* errors */
|
|
14
14
|
statuses.codes
|
|
15
|
-
.filter(code => code >= 400 && code < 600)
|
|
16
|
-
.forEach(code => {
|
|
15
|
+
.filter((code) => code >= 400 && code < 600)
|
|
16
|
+
.forEach((code) => {
|
|
17
17
|
const name = statuses(code);
|
|
18
18
|
const camelCasedName = camelCase(name);
|
|
19
|
-
app.response[camelCasedName] = function(message, details = {}) {
|
|
19
|
+
app.response[camelCasedName] = function responseCode(message, details = {}) {
|
|
20
20
|
const httpError = createError(code, message, { details });
|
|
21
21
|
const { status, body } = formatHttpError(httpError);
|
|
22
22
|
this.status = status;
|
|
@@ -26,17 +26,17 @@ const addCustomMethods = app => {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
/* send, created, deleted */
|
|
29
|
-
app.response.send = function(data, status = 200) {
|
|
29
|
+
app.response.send = function send(data, status = 200) {
|
|
30
30
|
this.status = status;
|
|
31
31
|
this.body = data;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
app.response.created = function(data) {
|
|
34
|
+
app.response.created = function created(data) {
|
|
35
35
|
this.status = 201;
|
|
36
36
|
this.body = data;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
app.response.deleted = function(data) {
|
|
39
|
+
app.response.deleted = function deleted(data) {
|
|
40
40
|
if (isNil(data)) {
|
|
41
41
|
this.status = 204;
|
|
42
42
|
} else {
|
|
@@ -45,10 +45,7 @@ const addCustomMethods = app => {
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
delegator
|
|
49
|
-
.method('send')
|
|
50
|
-
.method('created')
|
|
51
|
-
.method('deleted');
|
|
48
|
+
delegator.method('send').method('created').method('deleted');
|
|
52
49
|
|
|
53
50
|
return app;
|
|
54
51
|
};
|
|
@@ -90,7 +90,7 @@ const resolveMiddlewares = (config, strapi) => {
|
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
middlewares.forEach(middleware => {
|
|
93
|
+
middlewares.forEach((middleware) => {
|
|
94
94
|
// NOTE: we replace null middlewares by a dumb one to avoid having to filter later on
|
|
95
95
|
if (isNil(middleware.handler)) {
|
|
96
96
|
middleware.handler = (_, next) => next();
|
|
@@ -6,7 +6,7 @@ const { policy: policyUtils } = require('@strapi/utils');
|
|
|
6
6
|
|
|
7
7
|
const getPoliciesConfig = propOr([], 'config.policies');
|
|
8
8
|
|
|
9
|
-
const resolvePolicies = route => {
|
|
9
|
+
const resolvePolicies = (route) => {
|
|
10
10
|
const policiesConfig = getPoliciesConfig(route);
|
|
11
11
|
const resolvedPolicies = policyUtils.resolve(policiesConfig, route.info);
|
|
12
12
|
|
|
@@ -34,7 +34,7 @@ const requiredMiddlewares = [
|
|
|
34
34
|
];
|
|
35
35
|
|
|
36
36
|
const middlewareConfigSchema = yup.array().of(
|
|
37
|
-
yup.lazy(value => {
|
|
37
|
+
yup.lazy((value) => {
|
|
38
38
|
if (typeof value === 'string') {
|
|
39
39
|
return yup.string().required();
|
|
40
40
|
}
|
|
@@ -58,7 +58,7 @@ const middlewareConfigSchema = yup.array().of(
|
|
|
58
58
|
* Register middlewares in router
|
|
59
59
|
* @param {Strapi} strapi
|
|
60
60
|
*/
|
|
61
|
-
const registerApplicationMiddlewares = async strapi => {
|
|
61
|
+
const registerApplicationMiddlewares = async (strapi) => {
|
|
62
62
|
const middlewareConfig = strapi.config.get('middlewares', defaultConfig);
|
|
63
63
|
|
|
64
64
|
await validateMiddlewareConfig(middlewareConfig);
|
|
@@ -78,7 +78,7 @@ const registerApplicationMiddlewares = async strapi => {
|
|
|
78
78
|
*
|
|
79
79
|
* @param {MiddlewaresConfig} config
|
|
80
80
|
*/
|
|
81
|
-
const validateMiddlewareConfig = async config => {
|
|
81
|
+
const validateMiddlewareConfig = async (config) => {
|
|
82
82
|
try {
|
|
83
83
|
await middlewareConfigSchema.validate(config, { strict: true, abortEarly: false });
|
|
84
84
|
} catch (error) {
|
|
@@ -92,9 +92,9 @@ const validateMiddlewareConfig = async config => {
|
|
|
92
92
|
* Check if some required middlewares are missing in configure middlewares
|
|
93
93
|
* @param {Middlewares} middlewares
|
|
94
94
|
*/
|
|
95
|
-
const checkRequiredMiddlewares = middlewares => {
|
|
96
|
-
const missingMiddlewares = requiredMiddlewares.filter(name => {
|
|
97
|
-
return middlewares.findIndex(mdl => mdl.name === name) === -1;
|
|
95
|
+
const checkRequiredMiddlewares = (middlewares) => {
|
|
96
|
+
const missingMiddlewares = requiredMiddlewares.filter((name) => {
|
|
97
|
+
return middlewares.findIndex((mdl) => mdl.name === name) === -1;
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
if (missingMiddlewares.length > 0) {
|
|
@@ -104,8 +104,6 @@ const checkRequiredMiddlewares = middlewares => {
|
|
|
104
104
|
)}".`
|
|
105
105
|
);
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
return;
|
|
109
107
|
};
|
|
110
108
|
|
|
111
109
|
module.exports = registerApplicationMiddlewares;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
|
|
5
|
-
const createRouteScopeGenerator = namespace => route => {
|
|
5
|
+
const createRouteScopeGenerator = (namespace) => (route) => {
|
|
6
6
|
const prefix = namespace.endsWith('::') ? namespace : `${namespace}.`;
|
|
7
7
|
|
|
8
8
|
if (typeof route.handler === 'string') {
|
|
@@ -20,7 +20,7 @@ const createRouteScopeGenerator = namespace => route => {
|
|
|
20
20
|
* Register all routes
|
|
21
21
|
* @param {import('../../').Strapi} strapi
|
|
22
22
|
*/
|
|
23
|
-
module.exports = strapi => {
|
|
23
|
+
module.exports = (strapi) => {
|
|
24
24
|
registerAdminRoutes(strapi);
|
|
25
25
|
registerAPIRoutes(strapi);
|
|
26
26
|
registerPluginRoutes(strapi);
|
|
@@ -30,10 +30,10 @@ module.exports = strapi => {
|
|
|
30
30
|
* Register admin routes
|
|
31
31
|
* @param {import('../../').Strapi} strapi
|
|
32
32
|
*/
|
|
33
|
-
const registerAdminRoutes = strapi => {
|
|
33
|
+
const registerAdminRoutes = (strapi) => {
|
|
34
34
|
const generateRouteScope = createRouteScopeGenerator(`admin::`);
|
|
35
35
|
|
|
36
|
-
strapi.admin.routes.forEach(route => {
|
|
36
|
+
strapi.admin.routes.forEach((route) => {
|
|
37
37
|
generateRouteScope(route);
|
|
38
38
|
route.info = { pluginName: 'admin' };
|
|
39
39
|
});
|
|
@@ -49,14 +49,14 @@ const registerAdminRoutes = strapi => {
|
|
|
49
49
|
* Register plugin routes
|
|
50
50
|
* @param {import('../../').Strapi} strapi
|
|
51
51
|
*/
|
|
52
|
-
const registerPluginRoutes = strapi => {
|
|
52
|
+
const registerPluginRoutes = (strapi) => {
|
|
53
53
|
for (const pluginName in strapi.plugins) {
|
|
54
54
|
const plugin = strapi.plugins[pluginName];
|
|
55
55
|
|
|
56
56
|
const generateRouteScope = createRouteScopeGenerator(`plugin::${pluginName}`);
|
|
57
57
|
|
|
58
58
|
if (Array.isArray(plugin.routes)) {
|
|
59
|
-
plugin.routes.forEach(route => {
|
|
59
|
+
plugin.routes.forEach((route) => {
|
|
60
60
|
generateRouteScope(route);
|
|
61
61
|
route.info = { pluginName };
|
|
62
62
|
});
|
|
@@ -67,10 +67,10 @@ const registerPluginRoutes = strapi => {
|
|
|
67
67
|
routes: plugin.routes,
|
|
68
68
|
});
|
|
69
69
|
} else {
|
|
70
|
-
_.forEach(plugin.routes, router => {
|
|
70
|
+
_.forEach(plugin.routes, (router) => {
|
|
71
71
|
router.type = router.type || 'admin';
|
|
72
72
|
router.prefix = `/${pluginName}`;
|
|
73
|
-
router.routes.forEach(route => {
|
|
73
|
+
router.routes.forEach((route) => {
|
|
74
74
|
generateRouteScope(route);
|
|
75
75
|
route.info = { pluginName };
|
|
76
76
|
});
|
|
@@ -85,17 +85,17 @@ const registerPluginRoutes = strapi => {
|
|
|
85
85
|
* Register api routes
|
|
86
86
|
* @param {import('../../').Strapi} strapi
|
|
87
87
|
*/
|
|
88
|
-
const registerAPIRoutes = strapi => {
|
|
88
|
+
const registerAPIRoutes = (strapi) => {
|
|
89
89
|
for (const apiName in strapi.api) {
|
|
90
90
|
const api = strapi.api[apiName];
|
|
91
91
|
|
|
92
92
|
const generateRouteScope = createRouteScopeGenerator(`api::${apiName}`);
|
|
93
93
|
|
|
94
|
-
_.forEach(api.routes, router => {
|
|
94
|
+
_.forEach(api.routes, (router) => {
|
|
95
95
|
// TODO: remove once auth setup
|
|
96
96
|
// pass meta down to compose endpoint
|
|
97
97
|
router.type = 'content-api';
|
|
98
|
-
router.routes.forEach(route => {
|
|
98
|
+
router.routes.forEach((route) => {
|
|
99
99
|
generateRouteScope(route);
|
|
100
100
|
route.info = { apiName };
|
|
101
101
|
});
|
|
@@ -7,7 +7,7 @@ const { yup } = require('@strapi/utils');
|
|
|
7
7
|
|
|
8
8
|
const createEndpointComposer = require('./compose-endpoint');
|
|
9
9
|
|
|
10
|
-
const policyOrMiddlewareSchema = yup.lazy(value => {
|
|
10
|
+
const policyOrMiddlewareSchema = yup.lazy((value) => {
|
|
11
11
|
if (typeof value === 'string') {
|
|
12
12
|
return yup.string().required();
|
|
13
13
|
}
|
|
@@ -23,12 +23,9 @@ const policyOrMiddlewareSchema = yup.lazy(value => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
const routeSchema = yup.object({
|
|
26
|
-
method: yup
|
|
27
|
-
.string()
|
|
28
|
-
.oneOf(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ALL'])
|
|
29
|
-
.required(),
|
|
26
|
+
method: yup.string().oneOf(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ALL']).required(),
|
|
30
27
|
path: yup.string().required(),
|
|
31
|
-
handler: yup.lazy(value => {
|
|
28
|
+
handler: yup.lazy((value) => {
|
|
32
29
|
if (typeof value === 'string') {
|
|
33
30
|
return yup.string().required();
|
|
34
31
|
}
|
|
@@ -37,38 +34,26 @@ const routeSchema = yup.object({
|
|
|
37
34
|
return yup.array().required();
|
|
38
35
|
}
|
|
39
36
|
|
|
40
|
-
return yup
|
|
41
|
-
.mixed()
|
|
42
|
-
.isFunction()
|
|
43
|
-
.required();
|
|
37
|
+
return yup.mixed().isFunction().required();
|
|
44
38
|
}),
|
|
45
39
|
config: yup
|
|
46
40
|
.object({
|
|
47
|
-
auth: yup.lazy(value => {
|
|
41
|
+
auth: yup.lazy((value) => {
|
|
48
42
|
if (value === false) {
|
|
49
43
|
return yup.boolean().required();
|
|
50
44
|
}
|
|
51
45
|
|
|
52
46
|
return yup.object({
|
|
53
|
-
scope: yup
|
|
54
|
-
.array()
|
|
55
|
-
.of(yup.string())
|
|
56
|
-
.required(),
|
|
47
|
+
scope: yup.array().of(yup.string()).required(),
|
|
57
48
|
});
|
|
58
49
|
}),
|
|
59
|
-
policies: yup
|
|
60
|
-
|
|
61
|
-
.of(policyOrMiddlewareSchema)
|
|
62
|
-
.notRequired(),
|
|
63
|
-
middlewares: yup
|
|
64
|
-
.array()
|
|
65
|
-
.of(policyOrMiddlewareSchema)
|
|
66
|
-
.notRequired(),
|
|
50
|
+
policies: yup.array().of(policyOrMiddlewareSchema).notRequired(),
|
|
51
|
+
middlewares: yup.array().of(policyOrMiddlewareSchema).notRequired(),
|
|
67
52
|
})
|
|
68
53
|
.notRequired(),
|
|
69
54
|
});
|
|
70
55
|
|
|
71
|
-
const validateRouteConfig = routeConfig => {
|
|
56
|
+
const validateRouteConfig = (routeConfig) => {
|
|
72
57
|
try {
|
|
73
58
|
return routeSchema.validateSync(routeConfig, {
|
|
74
59
|
strict: true,
|
|
@@ -96,11 +81,11 @@ const createRouteManager = (strapi, opts = {}) => {
|
|
|
96
81
|
|
|
97
82
|
const addRoutes = (routes, router) => {
|
|
98
83
|
if (Array.isArray(routes)) {
|
|
99
|
-
routes.forEach(route => createRoute(route, router));
|
|
84
|
+
routes.forEach((route) => createRoute(route, router));
|
|
100
85
|
} else if (routes.routes) {
|
|
101
86
|
const subRouter = new Router({ prefix: routes.prefix });
|
|
102
87
|
|
|
103
|
-
routes.routes.forEach(route => {
|
|
88
|
+
routes.routes.forEach((route) => {
|
|
104
89
|
const hasPrefix = has('prefix', route.config);
|
|
105
90
|
createRoute(route, hasPrefix ? router : subRouter);
|
|
106
91
|
});
|
|
@@ -18,12 +18,12 @@ module.exports = async (uid, entity, files) => {
|
|
|
18
18
|
|
|
19
19
|
const uploadService = strapi.plugin('upload').service('upload');
|
|
20
20
|
|
|
21
|
-
const findModelFromUploadPath = path => {
|
|
21
|
+
const findModelFromUploadPath = (path) => {
|
|
22
22
|
if (path.length === 0) {
|
|
23
23
|
return uid;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const currentPath = [];
|
|
27
27
|
let tmpModel = modelDef;
|
|
28
28
|
let modelUID = uid;
|
|
29
29
|
|
|
@@ -75,5 +75,5 @@ module.exports = async (uid, entity, files) => {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
await Promise.all(Object.keys(files).map(key => doUpload(key, files[key])));
|
|
78
|
+
await Promise.all(Object.keys(files).map((key) => doUpload(key, files[key])));
|
|
79
79
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The event hub is Strapi's event control center.
|
|
3
3
|
*/
|
|
4
|
+
|
|
4
5
|
'use strict';
|
|
5
6
|
|
|
6
7
|
const debug = require('debug')('strapi:webhook');
|
|
@@ -51,7 +52,7 @@ class WebhookRunner {
|
|
|
51
52
|
);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
const listen = info => {
|
|
55
|
+
const listen = (info) => {
|
|
55
56
|
this.queue.enqueue({ event, info });
|
|
56
57
|
};
|
|
57
58
|
|
|
@@ -62,10 +63,10 @@ class WebhookRunner {
|
|
|
62
63
|
async executeListener({ event, info }) {
|
|
63
64
|
debug(`Executing webhook for event '${event}'`);
|
|
64
65
|
const webhooks = this.webhooksMap.get(event) || [];
|
|
65
|
-
const activeWebhooks = webhooks.filter(webhook => webhook.isEnabled === true);
|
|
66
|
+
const activeWebhooks = webhooks.filter((webhook) => webhook.isEnabled === true);
|
|
66
67
|
|
|
67
68
|
for (const webhook of activeWebhooks) {
|
|
68
|
-
await this.run(webhook, event, info).catch(error => {
|
|
69
|
+
await this.run(webhook, event, info).catch((error) => {
|
|
69
70
|
this.logger.error('Error running webhook');
|
|
70
71
|
this.logger.error(error);
|
|
71
72
|
});
|
|
@@ -90,7 +91,7 @@ class WebhookRunner {
|
|
|
90
91
|
},
|
|
91
92
|
timeout: 10000,
|
|
92
93
|
})
|
|
93
|
-
.then(async res => {
|
|
94
|
+
.then(async (res) => {
|
|
94
95
|
if (res.ok) {
|
|
95
96
|
return {
|
|
96
97
|
statusCode: res.status,
|
|
@@ -102,7 +103,7 @@ class WebhookRunner {
|
|
|
102
103
|
message: await res.text(),
|
|
103
104
|
};
|
|
104
105
|
})
|
|
105
|
-
.catch(err => {
|
|
106
|
+
.catch((err) => {
|
|
106
107
|
return {
|
|
107
108
|
statusCode: 500,
|
|
108
109
|
message: err.message,
|
|
@@ -114,7 +115,7 @@ class WebhookRunner {
|
|
|
114
115
|
debug(`Registering webhook '${webhook.id}'`);
|
|
115
116
|
const { events } = webhook;
|
|
116
117
|
|
|
117
|
-
events.forEach(event => {
|
|
118
|
+
events.forEach((event) => {
|
|
118
119
|
if (this.webhooksMap.has(event)) {
|
|
119
120
|
this.webhooksMap.get(event).push(webhook);
|
|
120
121
|
} else {
|
|
@@ -134,7 +135,7 @@ class WebhookRunner {
|
|
|
134
135
|
debug(`Unregistering webhook '${webhook.id}'`);
|
|
135
136
|
|
|
136
137
|
this.webhooksMap.forEach((webhooks, event) => {
|
|
137
|
-
const filteredWebhooks = webhooks.filter(value => value.id !== webhook.id);
|
|
138
|
+
const filteredWebhooks = webhooks.filter((value) => value.id !== webhook.id);
|
|
138
139
|
|
|
139
140
|
// Cleanup hanging listeners
|
|
140
141
|
if (filteredWebhooks.length === 0) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Webhook store is the implementation of webhook storage over the core_store
|
|
3
3
|
*/
|
|
4
|
+
|
|
4
5
|
'use strict';
|
|
5
6
|
|
|
6
7
|
const webhookModel = {
|
|
@@ -25,7 +26,7 @@ const webhookModel = {
|
|
|
25
26
|
},
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
const toDBObject = data => {
|
|
29
|
+
const toDBObject = (data) => {
|
|
29
30
|
return {
|
|
30
31
|
name: data.name,
|
|
31
32
|
url: data.url,
|
|
@@ -35,7 +36,7 @@ const toDBObject = data => {
|
|
|
35
36
|
};
|
|
36
37
|
};
|
|
37
38
|
|
|
38
|
-
const fromDBObject = row => {
|
|
39
|
+
const fromDBObject = (row) => {
|
|
39
40
|
return {
|
|
40
41
|
id: row.id,
|
|
41
42
|
name: row.name,
|
|
@@ -2,7 +2,8 @@ import type Koa from 'koa';
|
|
|
2
2
|
import { Database } from '@strapi/database';
|
|
3
3
|
|
|
4
4
|
import type { StringMap } from './utils';
|
|
5
|
-
import type { GenericController } from '
|
|
5
|
+
import type { GenericController } from '../../../core-api/controller'
|
|
6
|
+
import type { GenericService } from '../../../core-api/service'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* The Strapi interface implemented by the main Strapi class.
|
|
@@ -33,12 +34,12 @@ export interface Strapi {
|
|
|
33
34
|
*
|
|
34
35
|
* It returns all the registered services
|
|
35
36
|
*/
|
|
36
|
-
readonly services: StringMap<
|
|
37
|
+
readonly services: StringMap<GenericService>;
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Find a service using its unique identifier
|
|
40
41
|
*/
|
|
41
|
-
service<T extends
|
|
42
|
+
service<T extends GenericService = GenericService>(uid: string): T | undefined;
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
45
|
* Getter for the Strapi controllers container
|
package/lib/types/factories.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Service } from '../core-api/service';
|
|
1
|
+
import { Service,GenericService } from '../core-api/service';
|
|
2
2
|
import { Controller, GenericController } from '../core-api/controller';
|
|
3
3
|
import { Middleware } from '../middlewares';
|
|
4
4
|
import { Policy } from '../core/registries/policies';
|
|
@@ -47,14 +47,14 @@ interface Router {
|
|
|
47
47
|
type ControllerCallback<T extends GenericController = GenericController> = (params: {
|
|
48
48
|
strapi: Strapi;
|
|
49
49
|
}) => T;
|
|
50
|
-
type ServiceCallback<T extends
|
|
50
|
+
type ServiceCallback<T extends GenericService = GenericService> = (params: { strapi: Strapi }) => T;
|
|
51
51
|
|
|
52
52
|
export function createCoreRouter(uid: string, cfg?: RouterConfig = {}): () => Router;
|
|
53
53
|
export function createCoreController<T extends GenericController = GenericController>(
|
|
54
54
|
uid: string,
|
|
55
55
|
cfg?: ControllerCallback<T> | T = {}
|
|
56
56
|
): () => T & Controller;
|
|
57
|
-
export function createCoreService<T extends
|
|
57
|
+
export function createCoreService<T extends GenericService = GenericService>(
|
|
58
58
|
uid: string,
|
|
59
59
|
cfg?: ServiceCallback<T> | T = {}
|
|
60
60
|
): () => T;
|
package/lib/utils/addSlash.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
module.exports = path => {
|
|
3
|
+
module.exports = (path) => {
|
|
4
4
|
if (typeof path !== 'string') throw new Error('admin.url must be a string');
|
|
5
5
|
if (path === '' || path === '/') return '/';
|
|
6
6
|
|
|
7
|
-
if (path[0] != '/') path =
|
|
8
|
-
if (path[path.length - 1] != '/') path
|
|
7
|
+
if (path[0] != '/') path = `/${path}`;
|
|
8
|
+
if (path[path.length - 1] != '/') path += '/';
|
|
9
9
|
return path;
|
|
10
10
|
};
|
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;
|
package/lib/utils/run-checks.js
CHANGED
|
@@ -5,18 +5,18 @@ const fs = require('fs-extra');
|
|
|
5
5
|
|
|
6
6
|
const requiredPaths = ['api', 'extensions', 'plugins', 'config', 'public'];
|
|
7
7
|
const checkFoldersExist = ({ appPath }) => {
|
|
8
|
-
|
|
9
|
-
for (
|
|
8
|
+
const missingPaths = [];
|
|
9
|
+
for (const reqPath of requiredPaths) {
|
|
10
10
|
if (!fs.pathExistsSync(path.resolve(appPath, reqPath))) {
|
|
11
11
|
missingPaths.push(reqPath);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
if (missingPaths.length > 0) {
|
|
16
|
-
throw new Error(`Missing required folders:\n${missingPaths.map(p => `- ./${p}`).join('\n')}`);
|
|
16
|
+
throw new Error(`Missing required folders:\n${missingPaths.map((p) => `- ./${p}`).join('\n')}`);
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
module.exports = config => {
|
|
20
|
+
module.exports = (config) => {
|
|
21
21
|
checkFoldersExist(config);
|
|
22
22
|
};
|
package/lib/utils/signals.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const destroyOnSignal = strapi => {
|
|
3
|
+
const destroyOnSignal = (strapi) => {
|
|
4
4
|
let signalReceived = false;
|
|
5
5
|
|
|
6
6
|
// For unknown reasons, we receive signals 2 times.
|
|
@@ -14,7 +14,7 @@ const destroyOnSignal = strapi => {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
['SIGTERM', 'SIGINT'].forEach(signal => {
|
|
17
|
+
['SIGTERM', 'SIGINT'].forEach((signal) => {
|
|
18
18
|
process.on(signal, terminateStrapi);
|
|
19
19
|
});
|
|
20
20
|
};
|
|
@@ -6,7 +6,7 @@ const _ = require('lodash/fp');
|
|
|
6
6
|
const { getAbsoluteAdminUrl, getAbsoluteServerUrl } = require('@strapi/utils');
|
|
7
7
|
const ee = require('./ee');
|
|
8
8
|
|
|
9
|
-
module.exports = app => {
|
|
9
|
+
module.exports = (app) => {
|
|
10
10
|
return {
|
|
11
11
|
logStats() {
|
|
12
12
|
const columns = Math.min(process.stderr.columns, 80) - 2;
|
|
@@ -23,7 +23,7 @@ module.exports = app => {
|
|
|
23
23
|
|
|
24
24
|
infoTable.push(
|
|
25
25
|
[chalk.blue('Time'), `${new Date()}`],
|
|
26
|
-
[chalk.blue('Launched in'), Date.now() - app.config.launchedAt
|
|
26
|
+
[chalk.blue('Launched in'), `${Date.now() - app.config.launchedAt} ms`],
|
|
27
27
|
[chalk.blue('Environment'), app.config.environment],
|
|
28
28
|
[chalk.blue('Process PID'), process.pid],
|
|
29
29
|
[chalk.blue('Version'), `${app.config.info.strapi} (node ${process.version})`],
|
package/lib/utils/success.js
CHANGED
|
@@ -8,7 +8,7 @@ const boxen = require('boxen');
|
|
|
8
8
|
const chalk = require('chalk');
|
|
9
9
|
const { env } = require('@strapi/utils');
|
|
10
10
|
|
|
11
|
-
const pkg = require('../../../package');
|
|
11
|
+
const pkg = require('../../../package.json');
|
|
12
12
|
|
|
13
13
|
const CHECK_INTERVAL = 1000 * 60 * 60 * 24 * 1; // 1 day
|
|
14
14
|
const NOTIF_INTERVAL = 1000 * 60 * 60 * 24 * 7; // 1 week
|
|
@@ -31,7 +31,7 @@ Check out the new releases at: ${releaseLink}
|
|
|
31
31
|
`.trim();
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
const createUpdateNotifier = strapi => {
|
|
34
|
+
const createUpdateNotifier = (strapi) => {
|
|
35
35
|
let config = null;
|
|
36
36
|
|
|
37
37
|
try {
|
|
@@ -45,7 +45,7 @@ const createUpdateNotifier = strapi => {
|
|
|
45
45
|
// we silence the error
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
const checkUpdate = async checkInterval => {
|
|
48
|
+
const checkUpdate = async (checkInterval) => {
|
|
49
49
|
const now = Date.now();
|
|
50
50
|
const lastUpdateCheck = config.get('lastUpdateCheck') || 0;
|
|
51
51
|
if (lastUpdateCheck + checkInterval > now) {
|
|
@@ -63,7 +63,7 @@ const createUpdateNotifier = strapi => {
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
const display = notifInterval => {
|
|
66
|
+
const display = (notifInterval) => {
|
|
67
67
|
const now = Date.now();
|
|
68
68
|
const latestVersion = config.get('latest');
|
|
69
69
|
const lastNotification = config.get('lastNotification') || 0;
|