@strapi/strapi 4.0.0-next.9 → 4.0.3
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 +14 -14
- package/bin/strapi.js +37 -6
- package/lib/Strapi.js +140 -72
- package/lib/commands/build.js +21 -11
- package/lib/commands/console.js +1 -1
- package/lib/commands/content-types/list.js +22 -0
- package/lib/commands/controllers/list.js +22 -0
- package/lib/commands/develop.js +24 -27
- package/lib/commands/generate-template.js +4 -5
- package/lib/commands/hooks/list.js +22 -0
- package/lib/commands/middlewares/list.js +22 -0
- package/lib/commands/new.js +3 -1
- package/lib/commands/policies/list.js +22 -0
- package/lib/commands/routes/list.js +28 -0
- package/lib/commands/services/list.js +22 -0
- package/lib/commands/watchAdmin.js +18 -9
- package/lib/core/app-configuration/index.js +3 -19
- package/lib/core/bootstrap.js +3 -34
- package/lib/core/domain/content-type/index.js +3 -7
- package/lib/core/domain/module/index.js +8 -6
- package/lib/core/domain/module/validation.js +1 -4
- package/lib/core/loaders/admin.js +2 -2
- package/lib/core/loaders/apis.js +7 -7
- package/lib/core/loaders/components.js +3 -5
- package/lib/core/loaders/index.js +1 -0
- package/lib/core/loaders/middlewares.js +23 -123
- package/lib/core/loaders/plugins/get-enabled-plugins.js +55 -19
- package/lib/core/loaders/plugins/get-user-plugins-config.js +37 -0
- package/lib/core/loaders/plugins/index.js +30 -16
- package/lib/core/loaders/policies.js +1 -1
- package/lib/core/loaders/src-index.js +39 -0
- package/lib/core/registries/apis.js +2 -16
- package/lib/core/registries/content-types.js +50 -6
- package/lib/core/registries/controllers.d.ts +7 -0
- package/lib/core/registries/controllers.js +74 -3
- package/lib/core/registries/hooks.d.ts +20 -0
- package/lib/core/registries/hooks.js +87 -0
- package/lib/core/registries/middlewares.d.ts +5 -0
- package/lib/core/registries/middlewares.js +61 -2
- package/lib/core/registries/modules.js +3 -3
- package/lib/core/registries/plugins.js +2 -2
- package/lib/core/registries/policies.d.ts +9 -0
- package/lib/core/registries/policies.js +57 -6
- package/lib/core/registries/services.d.ts +7 -0
- package/lib/core/registries/services.js +71 -15
- package/lib/core-api/controller/collection-type.js +38 -11
- package/lib/core-api/controller/index.d.ts +25 -0
- package/lib/core-api/controller/index.js +30 -11
- package/lib/core-api/controller/single-type.js +26 -7
- package/lib/core-api/controller/transform.js +28 -3
- package/lib/core-api/routes/index.js +71 -0
- package/lib/core-api/service/collection-type.js +22 -27
- package/lib/core-api/service/index.d.ts +21 -0
- package/lib/core-api/service/index.js +9 -19
- package/lib/core-api/service/pagination.js +16 -16
- package/lib/core-api/service/single-type.js +17 -20
- package/lib/factories.d.ts +48 -0
- package/lib/factories.js +84 -0
- package/lib/index.d.ts +10 -31
- package/lib/index.js +5 -1
- package/lib/middlewares/body.js +33 -0
- package/lib/middlewares/compression.js +8 -0
- package/lib/middlewares/cors.js +58 -0
- package/lib/middlewares/errors.js +40 -0
- package/lib/middlewares/favicon.js +19 -0
- package/lib/middlewares/index.d.ts +5 -0
- package/lib/middlewares/index.js +30 -116
- package/lib/middlewares/ip.js +8 -0
- package/lib/middlewares/logger.js +27 -0
- package/lib/middlewares/powered-by.js +20 -0
- package/lib/middlewares/public/index.js +72 -77
- package/lib/middlewares/query.js +46 -0
- package/lib/middlewares/response-time.js +15 -0
- package/lib/middlewares/responses.js +19 -0
- package/lib/middlewares/security.js +51 -0
- package/lib/middlewares/session/index.js +6 -6
- package/lib/migrations/draft-publish.js +57 -0
- package/lib/services/auth/index.js +87 -0
- package/lib/services/core-store.js +64 -49
- package/lib/services/cron.js +54 -0
- package/lib/services/entity-service/attributes/index.js +31 -0
- package/lib/services/entity-service/attributes/transforms.js +20 -0
- package/lib/services/entity-service/components.js +39 -15
- package/lib/services/entity-service/index.d.ts +91 -0
- package/lib/services/entity-service/index.js +118 -60
- package/lib/services/entity-service/params.js +48 -81
- package/lib/services/entity-validator/index.js +76 -43
- package/lib/services/entity-validator/validators.js +131 -43
- package/lib/services/errors.js +77 -0
- package/lib/services/fs.js +1 -1
- package/lib/services/metrics/index.js +38 -36
- package/lib/services/server/admin-api.js +14 -0
- package/lib/services/server/api.js +36 -0
- package/lib/services/server/compose-endpoint.js +141 -0
- package/lib/services/server/content-api.js +16 -0
- package/lib/{server.js → services/server/http-server.js} +0 -0
- package/lib/services/server/index.js +127 -0
- package/lib/services/server/koa.js +64 -0
- package/lib/services/server/middleware.js +122 -0
- package/lib/services/server/policy.js +32 -0
- package/lib/services/server/register-middlewares.js +110 -0
- package/lib/services/server/register-routes.js +106 -0
- package/lib/services/server/routing.js +120 -0
- package/lib/services/webhook-runner.js +1 -1
- package/lib/utils/ee.js +3 -3
- package/lib/utils/get-dirs.js +17 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/signals.js +24 -0
- package/lib/utils/update-notifier/index.js +2 -1
- package/package.json +94 -93
- package/lib/core/app-configuration/load-functions.js +0 -28
- package/lib/core-api/index.js +0 -39
- package/lib/middlewares/boom/defaults.json +0 -5
- package/lib/middlewares/boom/index.js +0 -147
- package/lib/middlewares/cors/index.js +0 -66
- package/lib/middlewares/cron/defaults.json +0 -5
- package/lib/middlewares/cron/index.js +0 -43
- package/lib/middlewares/favicon/defaults.json +0 -7
- package/lib/middlewares/favicon/index.js +0 -32
- package/lib/middlewares/gzip/defaults.json +0 -6
- package/lib/middlewares/gzip/index.js +0 -19
- package/lib/middlewares/helmet/defaults.json +0 -18
- package/lib/middlewares/helmet/index.js +0 -9
- package/lib/middlewares/ip/defaults.json +0 -7
- package/lib/middlewares/ip/index.js +0 -25
- package/lib/middlewares/language/defaults.json +0 -9
- package/lib/middlewares/language/index.js +0 -40
- package/lib/middlewares/logger/defaults.json +0 -5
- package/lib/middlewares/logger/index.js +0 -37
- package/lib/middlewares/parser/defaults.json +0 -11
- package/lib/middlewares/parser/index.js +0 -72
- package/lib/middlewares/poweredBy/defaults.json +0 -5
- package/lib/middlewares/poweredBy/index.js +0 -16
- package/lib/middlewares/public/defaults.json +0 -8
- package/lib/middlewares/responseTime/defaults.json +0 -5
- package/lib/middlewares/responseTime/index.js +0 -25
- package/lib/middlewares/responses/defaults.json +0 -5
- package/lib/middlewares/responses/index.js +0 -18
- package/lib/middlewares/router/defaults.json +0 -7
- package/lib/middlewares/router/index.js +0 -72
- package/lib/middlewares/router/utils/compose-endpoint.js +0 -169
- package/lib/utils/get-prefixed-dependencies.js +0 -7
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
|
|
5
|
+
const createRouteScopeGenerator = namespace => route => {
|
|
6
|
+
const prefix = namespace.endsWith('::') ? namespace : `${namespace}.`;
|
|
7
|
+
|
|
8
|
+
if (typeof route.handler === 'string') {
|
|
9
|
+
_.defaultsDeep(route, {
|
|
10
|
+
config: {
|
|
11
|
+
auth: {
|
|
12
|
+
scope: [`${route.handler.startsWith(prefix) ? '' : prefix}${route.handler}`],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Register all routes
|
|
21
|
+
* @param {import('../../').Strapi} strapi
|
|
22
|
+
*/
|
|
23
|
+
module.exports = strapi => {
|
|
24
|
+
registerAdminRoutes(strapi);
|
|
25
|
+
registerAPIRoutes(strapi);
|
|
26
|
+
registerPluginRoutes(strapi);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Register admin routes
|
|
31
|
+
* @param {import('../../').Strapi} strapi
|
|
32
|
+
*/
|
|
33
|
+
const registerAdminRoutes = strapi => {
|
|
34
|
+
const generateRouteScope = createRouteScopeGenerator(`admin::`);
|
|
35
|
+
|
|
36
|
+
strapi.admin.routes.forEach(route => {
|
|
37
|
+
generateRouteScope(route);
|
|
38
|
+
route.info = { pluginName: 'admin' };
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
strapi.server.routes({
|
|
42
|
+
type: 'admin',
|
|
43
|
+
prefix: '/admin',
|
|
44
|
+
routes: strapi.admin.routes,
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Register plugin routes
|
|
50
|
+
* @param {import('../../').Strapi} strapi
|
|
51
|
+
*/
|
|
52
|
+
const registerPluginRoutes = strapi => {
|
|
53
|
+
for (const pluginName in strapi.plugins) {
|
|
54
|
+
const plugin = strapi.plugins[pluginName];
|
|
55
|
+
|
|
56
|
+
const generateRouteScope = createRouteScopeGenerator(`plugin::${pluginName}`);
|
|
57
|
+
|
|
58
|
+
if (Array.isArray(plugin.routes)) {
|
|
59
|
+
plugin.routes.forEach(route => {
|
|
60
|
+
generateRouteScope(route);
|
|
61
|
+
route.info = { pluginName };
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
strapi.server.routes({
|
|
65
|
+
type: 'admin',
|
|
66
|
+
prefix: `/${pluginName}`,
|
|
67
|
+
routes: plugin.routes,
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
_.forEach(plugin.routes, router => {
|
|
71
|
+
router.type = router.type || 'admin';
|
|
72
|
+
router.prefix = `/${pluginName}`;
|
|
73
|
+
router.routes.forEach(route => {
|
|
74
|
+
generateRouteScope(route);
|
|
75
|
+
route.info = { pluginName };
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
strapi.server.routes(router);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Register api routes
|
|
86
|
+
* @param {import('../../').Strapi} strapi
|
|
87
|
+
*/
|
|
88
|
+
const registerAPIRoutes = strapi => {
|
|
89
|
+
for (const apiName in strapi.api) {
|
|
90
|
+
const api = strapi.api[apiName];
|
|
91
|
+
|
|
92
|
+
const generateRouteScope = createRouteScopeGenerator(`api::${apiName}`);
|
|
93
|
+
|
|
94
|
+
_.forEach(api.routes, router => {
|
|
95
|
+
// TODO: remove once auth setup
|
|
96
|
+
// pass meta down to compose endpoint
|
|
97
|
+
router.type = 'content-api';
|
|
98
|
+
router.routes.forEach(route => {
|
|
99
|
+
generateRouteScope(route);
|
|
100
|
+
route.info = { apiName };
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return strapi.server.routes(router);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Router = require('@koa/router');
|
|
4
|
+
const _ = require('lodash');
|
|
5
|
+
const { has } = require('lodash/fp');
|
|
6
|
+
const { yup } = require('@strapi/utils');
|
|
7
|
+
|
|
8
|
+
const createEndpointComposer = require('./compose-endpoint');
|
|
9
|
+
|
|
10
|
+
const policyOrMiddlewareSchema = yup.lazy(value => {
|
|
11
|
+
if (typeof value === 'string') {
|
|
12
|
+
return yup.string().required();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (typeof value === 'function') {
|
|
16
|
+
return yup.mixed().isFunction();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return yup.object({
|
|
20
|
+
name: yup.string().required(),
|
|
21
|
+
options: yup.object().notRequired(), // any options
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const routeSchema = yup.object({
|
|
26
|
+
method: yup
|
|
27
|
+
.string()
|
|
28
|
+
.oneOf(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ALL'])
|
|
29
|
+
.required(),
|
|
30
|
+
path: yup.string().required(),
|
|
31
|
+
handler: yup.lazy(value => {
|
|
32
|
+
if (typeof value === 'string') {
|
|
33
|
+
return yup.string().required();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
return yup.array().required();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return yup
|
|
41
|
+
.mixed()
|
|
42
|
+
.isFunction()
|
|
43
|
+
.required();
|
|
44
|
+
}),
|
|
45
|
+
config: yup
|
|
46
|
+
.object({
|
|
47
|
+
auth: yup.lazy(value => {
|
|
48
|
+
if (value === false) {
|
|
49
|
+
return yup.boolean().required();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return yup.object({
|
|
53
|
+
scope: yup
|
|
54
|
+
.array()
|
|
55
|
+
.of(yup.string())
|
|
56
|
+
.required(),
|
|
57
|
+
});
|
|
58
|
+
}),
|
|
59
|
+
policies: yup
|
|
60
|
+
.array()
|
|
61
|
+
.of(policyOrMiddlewareSchema)
|
|
62
|
+
.notRequired(),
|
|
63
|
+
middlewares: yup
|
|
64
|
+
.array()
|
|
65
|
+
.of(policyOrMiddlewareSchema)
|
|
66
|
+
.notRequired(),
|
|
67
|
+
})
|
|
68
|
+
.notRequired(),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const validateRouteConfig = routeConfig => {
|
|
72
|
+
try {
|
|
73
|
+
return routeSchema.validateSync(routeConfig, {
|
|
74
|
+
strict: true,
|
|
75
|
+
abortEarly: false,
|
|
76
|
+
stripUnknown: true,
|
|
77
|
+
});
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw new Error('Invalid route config', error.message);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const createRouteManager = (strapi, opts = {}) => {
|
|
84
|
+
const { type } = opts;
|
|
85
|
+
|
|
86
|
+
const composeEndpoint = createEndpointComposer(strapi);
|
|
87
|
+
|
|
88
|
+
const createRoute = (route, router) => {
|
|
89
|
+
validateRouteConfig(route);
|
|
90
|
+
|
|
91
|
+
// NOTE: the router type is used to tag controller actions and for authentication / authorization so we need to pass this info down to the route level
|
|
92
|
+
_.set(route, 'info.type', type || 'admin');
|
|
93
|
+
|
|
94
|
+
composeEndpoint(route, { router });
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const addRoutes = (routes, router) => {
|
|
98
|
+
if (Array.isArray(routes)) {
|
|
99
|
+
routes.forEach(route => createRoute(route, router));
|
|
100
|
+
} else if (routes.routes) {
|
|
101
|
+
const subRouter = new Router({ prefix: routes.prefix });
|
|
102
|
+
|
|
103
|
+
routes.routes.forEach(route => {
|
|
104
|
+
const hasPrefix = has('prefix', route.config);
|
|
105
|
+
createRoute(route, hasPrefix ? router : subRouter);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return router.use(subRouter.routes(), subRouter.allowedMethods());
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
addRoutes,
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
module.exports = {
|
|
118
|
+
validateRouteConfig,
|
|
119
|
+
createRouteManager,
|
|
120
|
+
};
|
package/lib/utils/ee.js
CHANGED
|
@@ -78,7 +78,7 @@ module.exports = ({ dir, logger = noLog }) => {
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
Object.defineProperty(module.exports, 'licenseInfo', {
|
|
81
|
-
get
|
|
81
|
+
get() {
|
|
82
82
|
mustHaveKey('licenseInfo');
|
|
83
83
|
return internals.licenseInfo;
|
|
84
84
|
},
|
|
@@ -87,7 +87,7 @@ Object.defineProperty(module.exports, 'licenseInfo', {
|
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
Object.defineProperty(module.exports, 'isEE', {
|
|
90
|
-
get
|
|
90
|
+
get() {
|
|
91
91
|
mustHaveKey('isEE');
|
|
92
92
|
return internals.isEE;
|
|
93
93
|
},
|
|
@@ -96,7 +96,7 @@ Object.defineProperty(module.exports, 'isEE', {
|
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
Object.defineProperty(module.exports, 'features', {
|
|
99
|
-
get
|
|
99
|
+
get() {
|
|
100
100
|
mustHaveKey('licenseInfo');
|
|
101
101
|
|
|
102
102
|
const { type: licenseType } = module.exports.licenseInfo;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { join } = require('path');
|
|
4
|
+
|
|
5
|
+
const getDirs = root => ({
|
|
6
|
+
root,
|
|
7
|
+
src: join(root, 'src'),
|
|
8
|
+
api: join(root, 'src', 'api'),
|
|
9
|
+
components: join(root, 'src', 'components'),
|
|
10
|
+
extensions: join(root, 'src', 'extensions'),
|
|
11
|
+
policies: join(root, 'src', 'policies'),
|
|
12
|
+
middlewares: join(root, 'src', 'middlewares'),
|
|
13
|
+
config: join(root, 'config'),
|
|
14
|
+
public: join(root, 'public'),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
module.exports = getDirs;
|
package/lib/utils/index.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const destroyOnSignal = strapi => {
|
|
4
|
+
let signalReceived = false;
|
|
5
|
+
|
|
6
|
+
// For unknown reasons, we receive signals 2 times.
|
|
7
|
+
// As a temporary fix, we ignore the signals received after the first one.
|
|
8
|
+
|
|
9
|
+
const terminateStrapi = async () => {
|
|
10
|
+
if (!signalReceived) {
|
|
11
|
+
signalReceived = true;
|
|
12
|
+
await strapi.destroy();
|
|
13
|
+
process.exit();
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
['SIGTERM', 'SIGINT'].forEach(signal => {
|
|
18
|
+
process.on(signal, terminateStrapi);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
destroyOnSignal,
|
|
24
|
+
};
|
|
@@ -38,7 +38,7 @@ const createUpdateNotifier = strapi => {
|
|
|
38
38
|
config = new Configstore(
|
|
39
39
|
pkg.name,
|
|
40
40
|
{},
|
|
41
|
-
{ configPath: path.join(strapi.
|
|
41
|
+
{ configPath: path.join(strapi.dirs.root, '.strapi-updater.json') }
|
|
42
42
|
);
|
|
43
43
|
} catch {
|
|
44
44
|
// we don't have write access to the file system
|
|
@@ -67,6 +67,7 @@ const createUpdateNotifier = strapi => {
|
|
|
67
67
|
const now = Date.now();
|
|
68
68
|
const latestVersion = config.get('latest');
|
|
69
69
|
const lastNotification = config.get('lastNotification') || 0;
|
|
70
|
+
|
|
70
71
|
if (
|
|
71
72
|
!process.stdout.isTTY ||
|
|
72
73
|
lastNotification + notifInterval > now ||
|
package/package.json
CHANGED
|
@@ -1,97 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/strapi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite",
|
|
5
|
-
"homepage": "https://strapi.io",
|
|
6
|
-
"directories": {
|
|
7
|
-
"lib": "./lib",
|
|
8
|
-
"bin": "./bin"
|
|
9
|
-
},
|
|
10
|
-
"main": "./lib",
|
|
11
|
-
"types": "./lib/index.d.ts",
|
|
12
|
-
"bin": {
|
|
13
|
-
"strapi": "./bin/strapi.js"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@koa/cors": "^3.0.0",
|
|
17
|
-
"@strapi/admin": "^4.0.0-next.9",
|
|
18
|
-
"@strapi/database": "^4.0.0-next.9",
|
|
19
|
-
"@strapi/generate-new": "^4.0.0-next.9",
|
|
20
|
-
"@strapi/generators": "^4.0.0-next.9",
|
|
21
|
-
"@strapi/logger": "^4.0.0-next.9",
|
|
22
|
-
"@strapi/utils": "^4.0.0-next.9",
|
|
23
|
-
"async": "^2.1.2",
|
|
24
|
-
"boom": "^7.3.0",
|
|
25
|
-
"boxen": "4.2.0",
|
|
26
|
-
"chalk": "^4.1.1",
|
|
27
|
-
"chokidar": "3.5.1",
|
|
28
|
-
"ci-info": "3.1.1",
|
|
29
|
-
"cli-table3": "^0.6.0",
|
|
30
|
-
"commander": "6.1.0",
|
|
31
|
-
"configstore": "5.0.1",
|
|
32
|
-
"cross-spawn": "^7.0.3",
|
|
33
|
-
"debug": "^4.1.1",
|
|
34
|
-
"delegates": "^1.0.0",
|
|
35
|
-
"dotenv": "10.0.0",
|
|
36
|
-
"execa": "^1.0.0",
|
|
37
|
-
"fs-extra": "^9.1.0",
|
|
38
|
-
"glob": "^7.1.2",
|
|
39
|
-
"inquirer": "^6.2.1",
|
|
40
|
-
"is-docker": "2.2.1",
|
|
41
|
-
"koa": "^2.13.1",
|
|
42
|
-
"koa-body": "^4.2.0",
|
|
43
|
-
"koa-compose": "^4.1.0",
|
|
44
|
-
"koa-compress": "^5.0.1",
|
|
45
|
-
"koa-convert": "^2.0.0",
|
|
46
|
-
"koa-favicon": "^2.0.0",
|
|
47
|
-
"koa-helmet": "6.1.0",
|
|
48
|
-
"koa-i18n": "^2.1.0",
|
|
49
|
-
"koa-ip": "^2.0.0",
|
|
50
|
-
"koa-locale": "~1.3.0",
|
|
51
|
-
"koa-router": "^7.4.0",
|
|
52
|
-
"koa-session": "^6.2.0",
|
|
53
|
-
"koa-static": "^5.0.0",
|
|
54
|
-
"lodash": "4.17.21",
|
|
55
|
-
"node-fetch": "2.6.1",
|
|
56
|
-
"node-machine-id": "1.1.12",
|
|
57
|
-
"node-schedule": "1.3.2",
|
|
58
|
-
"open": "8.2.1",
|
|
59
|
-
"ora": "^5.4.0",
|
|
60
|
-
"package-json": "6.5.0",
|
|
61
|
-
"plop": "2.7.4",
|
|
62
|
-
"pluralize": "8.0.0",
|
|
63
|
-
"qs": "^6.10.1",
|
|
64
|
-
"resolve-cwd": "^3.0.0",
|
|
65
|
-
"rimraf": "^3.0.2",
|
|
66
|
-
"semver": "7.3.5"
|
|
67
|
-
},
|
|
68
|
-
"scripts": {
|
|
69
|
-
"postinstall": "node lib/utils/success.js"
|
|
70
|
-
},
|
|
71
|
-
"author": {
|
|
72
|
-
"email": "hi@strapi.io",
|
|
73
|
-
"name": "Strapi team",
|
|
74
|
-
"url": "https://strapi.io"
|
|
75
|
-
},
|
|
76
|
-
"maintainers": [
|
|
77
|
-
{
|
|
78
|
-
"name": "Strapi team",
|
|
79
|
-
"email": "hi@strapi.io",
|
|
80
|
-
"url": "https://strapi.io"
|
|
81
|
-
}
|
|
82
|
-
],
|
|
83
|
-
"repository": {
|
|
84
|
-
"type": "git",
|
|
85
|
-
"url": "git://github.com/strapi/strapi.git"
|
|
86
|
-
},
|
|
87
|
-
"bugs": {
|
|
88
|
-
"url": "https://github.com/strapi/strapi/issues"
|
|
89
|
-
},
|
|
90
|
-
"engines": {
|
|
91
|
-
"node": ">=12.x.x <=16.x.x",
|
|
92
|
-
"npm": ">=6.0.0"
|
|
93
|
-
},
|
|
94
|
-
"license": "SEE LICENSE IN LICENSE",
|
|
95
5
|
"keywords": [
|
|
96
6
|
"strapi",
|
|
97
7
|
"cms",
|
|
@@ -128,11 +38,102 @@
|
|
|
128
38
|
"backend",
|
|
129
39
|
"open source",
|
|
130
40
|
"self hosted",
|
|
131
|
-
"javascript",
|
|
132
41
|
"lerna",
|
|
133
42
|
"lernajs",
|
|
134
43
|
"react",
|
|
135
44
|
"reactjs"
|
|
136
45
|
],
|
|
137
|
-
"
|
|
46
|
+
"homepage": "https://strapi.io",
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/strapi/strapi/issues"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git://github.com/strapi/strapi.git"
|
|
53
|
+
},
|
|
54
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
55
|
+
"author": {
|
|
56
|
+
"name": "Strapi Solutions SAS",
|
|
57
|
+
"email": "hi@strapi.io",
|
|
58
|
+
"url": "https://strapi.io"
|
|
59
|
+
},
|
|
60
|
+
"maintainers": [
|
|
61
|
+
{
|
|
62
|
+
"name": "Strapi Solutions SAS",
|
|
63
|
+
"email": "hi@strapi.io",
|
|
64
|
+
"url": "https://strapi.io"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"main": "./lib",
|
|
68
|
+
"types": "./lib/index.d.ts",
|
|
69
|
+
"bin": {
|
|
70
|
+
"strapi": "./bin/strapi.js"
|
|
71
|
+
},
|
|
72
|
+
"directories": {
|
|
73
|
+
"lib": "./lib",
|
|
74
|
+
"bin": "./bin"
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"postinstall": "node lib/utils/success.js",
|
|
78
|
+
"test:unit": "jest --verbose"
|
|
79
|
+
},
|
|
80
|
+
"dependencies": {
|
|
81
|
+
"@koa/cors": "3.1.0",
|
|
82
|
+
"@koa/router": "10.1.1",
|
|
83
|
+
"@strapi/admin": "4.0.3",
|
|
84
|
+
"@strapi/database": "4.0.3",
|
|
85
|
+
"@strapi/generate-new": "4.0.3",
|
|
86
|
+
"@strapi/generators": "4.0.3",
|
|
87
|
+
"@strapi/logger": "4.0.3",
|
|
88
|
+
"@strapi/plugin-content-manager": "4.0.3",
|
|
89
|
+
"@strapi/plugin-content-type-builder": "4.0.3",
|
|
90
|
+
"@strapi/plugin-email": "4.0.3",
|
|
91
|
+
"@strapi/plugin-upload": "4.0.3",
|
|
92
|
+
"@strapi/utils": "4.0.3",
|
|
93
|
+
"bcryptjs": "2.4.3",
|
|
94
|
+
"boxen": "5.1.2",
|
|
95
|
+
"chalk": "4.1.2",
|
|
96
|
+
"chokidar": "3.5.2",
|
|
97
|
+
"ci-info": "3.2.0",
|
|
98
|
+
"cli-table3": "0.6.0",
|
|
99
|
+
"commander": "8.2.0",
|
|
100
|
+
"configstore": "5.0.1",
|
|
101
|
+
"debug": "4.3.2",
|
|
102
|
+
"delegates": "1.0.0",
|
|
103
|
+
"dotenv": "10.0.0",
|
|
104
|
+
"execa": "5.1.1",
|
|
105
|
+
"fs-extra": "10.0.0",
|
|
106
|
+
"glob": "7.2.0",
|
|
107
|
+
"http-errors": "1.8.0",
|
|
108
|
+
"inquirer": "8.2.0",
|
|
109
|
+
"is-docker": "2.2.1",
|
|
110
|
+
"koa": "2.13.3",
|
|
111
|
+
"koa-body": "4.2.0",
|
|
112
|
+
"koa-compose": "4.1.0",
|
|
113
|
+
"koa-compress": "5.1.0",
|
|
114
|
+
"koa-favicon": "2.1.0",
|
|
115
|
+
"koa-helmet": "6.1.0",
|
|
116
|
+
"koa-ip": "2.1.0",
|
|
117
|
+
"koa-session": "6.2.0",
|
|
118
|
+
"koa-static": "5.0.0",
|
|
119
|
+
"lodash": "4.17.21",
|
|
120
|
+
"node-fetch": "2.6.5",
|
|
121
|
+
"node-machine-id": "1.1.12",
|
|
122
|
+
"node-schedule": "2.0.0",
|
|
123
|
+
"open": "8.2.1",
|
|
124
|
+
"ora": "5.4.1",
|
|
125
|
+
"package-json": "7.0.0",
|
|
126
|
+
"qs": "6.10.1",
|
|
127
|
+
"resolve-cwd": "3.0.0",
|
|
128
|
+
"semver": "7.3.5",
|
|
129
|
+
"statuses": "2.0.1"
|
|
130
|
+
},
|
|
131
|
+
"devDependencies": {
|
|
132
|
+
"supertest": "^6.1.6"
|
|
133
|
+
},
|
|
134
|
+
"engines": {
|
|
135
|
+
"node": ">=12.22.0 <=16.x.x",
|
|
136
|
+
"npm": ">=6.0.0"
|
|
137
|
+
},
|
|
138
|
+
"gitHead": "48893ae3fc951b618fd8c4fdc6970e623d2c92db"
|
|
138
139
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { join, extname, basename } = require('path');
|
|
4
|
-
const fse = require('fs-extra');
|
|
5
|
-
|
|
6
|
-
module.exports = function loadFunctions(dir) {
|
|
7
|
-
const functions = {};
|
|
8
|
-
|
|
9
|
-
if (!fse.pathExistsSync(dir)) {
|
|
10
|
-
return functions;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const paths = fse.readdirSync(dir, { withFileTypes: true });
|
|
14
|
-
|
|
15
|
-
for (const fd of paths) {
|
|
16
|
-
const { name } = fd;
|
|
17
|
-
const fullPath = join(dir, name);
|
|
18
|
-
|
|
19
|
-
if (fd.isDirectory()) {
|
|
20
|
-
functions[name] = loadFunctions(fullPath);
|
|
21
|
-
} else if (fd.isFile() && extname(name) === '.js') {
|
|
22
|
-
const key = basename(name, '.js');
|
|
23
|
-
functions[key] = require(fullPath);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return functions;
|
|
28
|
-
};
|
package/lib/core-api/index.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core API
|
|
3
|
-
*/
|
|
4
|
-
'use strict';
|
|
5
|
-
|
|
6
|
-
const _ = require('lodash');
|
|
7
|
-
|
|
8
|
-
const createController = require('./controller');
|
|
9
|
-
const { createService } = require('./service');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Returns a service and a controller built based on the content type passed
|
|
13
|
-
*
|
|
14
|
-
* @param {object} opts options
|
|
15
|
-
* @param {object} opts.api api
|
|
16
|
-
* @param {object} opts.model model
|
|
17
|
-
* @param {object} opts.strapi strapi
|
|
18
|
-
* @returns {object} controller & service
|
|
19
|
-
*/
|
|
20
|
-
function createCoreApi({ api, model, strapi }) {
|
|
21
|
-
const { modelName } = model;
|
|
22
|
-
|
|
23
|
-
// find corresponding service and controller
|
|
24
|
-
const userService = _.get(api, ['services', modelName], {});
|
|
25
|
-
const userController = _.get(api, ['controllers', modelName], {});
|
|
26
|
-
|
|
27
|
-
const service = Object.assign(createService({ model, strapi }), userService);
|
|
28
|
-
|
|
29
|
-
const controller = Object.assign(createController({ service, model }), userController);
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
service,
|
|
33
|
-
controller,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
module.exports = {
|
|
38
|
-
createCoreApi,
|
|
39
|
-
};
|