@cloudimage-strapi/content-plugin 1.0.4 → 1.0.5
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 +2 -2
- package/dist/_chunks/App-BmZyLUWk.mjs +138 -0
- package/dist/_chunks/App-CRbNvJDt.js +138 -0
- package/dist/_chunks/en-DUVjg0jJ.js +16 -0
- package/dist/_chunks/en-r7lu9xMg.mjs +16 -0
- package/dist/_chunks/fr-DTrzyr9o.js +16 -0
- package/dist/_chunks/fr-Ge-jvwxL.mjs +16 -0
- package/dist/_chunks/index-4zkw0zS1.mjs +72 -0
- package/dist/_chunks/index-DfCnchyr.js +71 -0
- package/dist/admin/index.js +3 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/server/index.js +237 -0
- package/dist/server/index.mjs +238 -0
- package/package.json +57 -75
- package/LICENSE +0 -21
- package/admin/src/components/Initializer/index.js +0 -26
- package/admin/src/components/PluginIcon/index.js +0 -11
- package/admin/src/index.js +0 -63
- package/admin/src/pages/App/index.js +0 -25
- package/admin/src/pages/HomePage/index.js +0 -199
- package/admin/src/pluginId.js +0 -5
- package/admin/src/translations/en.json +0 -1
- package/admin/src/translations/fr.json +0 -1
- package/admin/src/utils/axiosInstance.js +0 -40
- package/admin/src/utils/getTrad.js +0 -5
- package/server/bootstrap.js +0 -25
- package/server/config/index.js +0 -6
- package/server/content-types/index.js +0 -3
- package/server/controllers/cloudimage-by-scaleflex.js +0 -40
- package/server/controllers/index.js +0 -7
- package/server/destroy.js +0 -5
- package/server/index.js +0 -25
- package/server/middlewares/index.js +0 -3
- package/server/policies/index.js +0 -3
- package/server/register.js +0 -65
- package/server/routes/index.js +0 -56
- package/server/services/cloudimage-by-scaleflex.js +0 -172
- package/server/services/index.js +0 -7
- package/strapi-admin.js +0 -3
- package/strapi-server.js +0 -3
package/admin/src/index.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
|
2
|
-
import pluginPkg from '../../package.json';
|
|
3
|
-
import pluginId from './pluginId';
|
|
4
|
-
import Initializer from './components/Initializer';
|
|
5
|
-
import PluginIcon from './components/PluginIcon';
|
|
6
|
-
|
|
7
|
-
const name = "cloudimage-by-scaleflex";
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
register(app) {
|
|
11
|
-
app.addMenuLink({
|
|
12
|
-
to: `/plugins/${pluginId}`,
|
|
13
|
-
icon: PluginIcon,
|
|
14
|
-
intlLabel: {
|
|
15
|
-
id: `${pluginId}.plugin.name`,
|
|
16
|
-
defaultMessage: 'Cloudimage by Scaleflex',
|
|
17
|
-
},
|
|
18
|
-
Component: async () => {
|
|
19
|
-
const component = await import(/* webpackChunkName: "[request]" */ './pages/App');
|
|
20
|
-
|
|
21
|
-
return component;
|
|
22
|
-
},
|
|
23
|
-
permissions: [
|
|
24
|
-
// Uncomment to set the permissions of the plugin here
|
|
25
|
-
// {
|
|
26
|
-
// action: '', // the action name should be plugin::plugin-name.actionType
|
|
27
|
-
// subject: null,
|
|
28
|
-
// },
|
|
29
|
-
],
|
|
30
|
-
});
|
|
31
|
-
app.registerPlugin({
|
|
32
|
-
id: pluginId,
|
|
33
|
-
initializer: Initializer,
|
|
34
|
-
isReady: false,
|
|
35
|
-
name,
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
bootstrap(app) {},
|
|
40
|
-
async registerTrads({ locales }) {
|
|
41
|
-
const importedTrads = await Promise.all(
|
|
42
|
-
locales.map(locale => {
|
|
43
|
-
return import(
|
|
44
|
-
/* webpackChunkName: "translation-[request]" */ `./translations/${locale}.json`
|
|
45
|
-
)
|
|
46
|
-
.then(({ default: data }) => {
|
|
47
|
-
return {
|
|
48
|
-
data: prefixPluginTranslations(data, pluginId),
|
|
49
|
-
locale,
|
|
50
|
-
};
|
|
51
|
-
})
|
|
52
|
-
.catch(() => {
|
|
53
|
-
return {
|
|
54
|
-
data: {},
|
|
55
|
-
locale,
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
})
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
return Promise.resolve(importedTrads);
|
|
62
|
-
},
|
|
63
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* This component is the skeleton around the actual pages, and should only
|
|
4
|
-
* contain code that should be seen on all pages. (e.g. navigation bar)
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import { Switch, Route } from 'react-router-dom';
|
|
10
|
-
import { NotFound } from '@strapi/helper-plugin';
|
|
11
|
-
import pluginId from '../../pluginId';
|
|
12
|
-
import HomePage from '../HomePage';
|
|
13
|
-
|
|
14
|
-
const App = () => {
|
|
15
|
-
return (
|
|
16
|
-
<div>
|
|
17
|
-
<Switch>
|
|
18
|
-
<Route path={`/plugins/${pluginId}`} component={HomePage} exact />
|
|
19
|
-
<Route component={NotFound} />
|
|
20
|
-
</Switch>
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export default App;
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
*
|
|
3
|
-
* HomePage
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import React, {memo, useState, useEffect} from 'react';
|
|
8
|
-
import { Stack, Box, Typography, Field, FieldLabel, FieldInput, Button, Alert, Radio, RadioGroup } from '@strapi/design-system';
|
|
9
|
-
import {request} from "@strapi/helper-plugin";
|
|
10
|
-
import pluginId from '../../pluginId';
|
|
11
|
-
|
|
12
|
-
const HomePage = () => {
|
|
13
|
-
const [config, setConfig] = useState(null);
|
|
14
|
-
const [loading, setLoading] = useState(true);
|
|
15
|
-
const [domain, setDomain] = useState('');
|
|
16
|
-
const [isV7, setIsV7] = useState(false);
|
|
17
|
-
const [isV7CheckSuccessful, setIsV7CheckSuccessful] = useState(true);
|
|
18
|
-
const [manualV7, setManualV7] = useState(false);
|
|
19
|
-
const [disabledAllButtons, setDisabledAllButtons] = useState(false);
|
|
20
|
-
const [success, setSuccess] = useState(false);
|
|
21
|
-
const [error, setError] = useState(false);
|
|
22
|
-
const [disableUpdateButtons, setDisableUpdateButtons] = useState(false);
|
|
23
|
-
const [updateCount, setUpdateCount] = useState(-1);
|
|
24
|
-
const [displayUpdateResult, setDisplayUpdateResult] = useState(false);
|
|
25
|
-
const [updateMessage, setUpdateMessage] = useState('');
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
request(`/${pluginId}/config`, {method: 'GET'}).then(config => {
|
|
29
|
-
setConfig(config);
|
|
30
|
-
setDomain(config.domain);
|
|
31
|
-
setLoading(false);
|
|
32
|
-
|
|
33
|
-
if (!config.domain || !config.hasOwnProperty('isV7'))
|
|
34
|
-
{
|
|
35
|
-
setDisableUpdateButtons(true);
|
|
36
|
-
}
|
|
37
|
-
else
|
|
38
|
-
{
|
|
39
|
-
setDisableUpdateButtons(false);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}, []);
|
|
43
|
-
|
|
44
|
-
if (loading)
|
|
45
|
-
{
|
|
46
|
-
return (
|
|
47
|
-
<Typography>fetching configuration...</Typography>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const saveConfiguration = async () => {
|
|
52
|
-
if (!domain)
|
|
53
|
-
{
|
|
54
|
-
setError(true);
|
|
55
|
-
setSuccess(false);
|
|
56
|
-
setDisabledAllButtons(false);
|
|
57
|
-
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
else
|
|
61
|
-
{
|
|
62
|
-
setError(false);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
setDisabledAllButtons(true);
|
|
66
|
-
|
|
67
|
-
// Check whether input is token or domain
|
|
68
|
-
let tokenOrDomain = '';
|
|
69
|
-
|
|
70
|
-
if (domain && domain.indexOf('.') === -1)
|
|
71
|
-
{
|
|
72
|
-
tokenOrDomain = `${domain}.cloudimg.io`.trim();
|
|
73
|
-
}
|
|
74
|
-
else
|
|
75
|
-
{
|
|
76
|
-
tokenOrDomain = domain.trim();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Check whether v7 or not
|
|
80
|
-
let v7Check = await request(`/${pluginId}/is-v7?domain=${tokenOrDomain}`, {method: 'GET'});
|
|
81
|
-
|
|
82
|
-
if (!v7Check.domainExists)
|
|
83
|
-
{
|
|
84
|
-
setError(true);
|
|
85
|
-
setSuccess(false);
|
|
86
|
-
setDisabledAllButtons(false);
|
|
87
|
-
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
else
|
|
91
|
-
{
|
|
92
|
-
setError(false);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
setIsV7CheckSuccessful(v7Check.isSuccess);
|
|
96
|
-
|
|
97
|
-
let isV7Overall = v7Check.isSuccess ? v7Check.isV7 : manualV7;
|
|
98
|
-
setIsV7(isV7Overall);
|
|
99
|
-
|
|
100
|
-
// POST to backend to set config
|
|
101
|
-
let config = {
|
|
102
|
-
domain: tokenOrDomain,
|
|
103
|
-
isV7: isV7Overall
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
let updatedConfigs = await request(`/${pluginId}/update-config`, {method: 'PUT', body: config});
|
|
107
|
-
|
|
108
|
-
setDomain(updatedConfigs.domain);
|
|
109
|
-
setSuccess(true);
|
|
110
|
-
setDisabledAllButtons(false);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const countUpdate = async () => {
|
|
114
|
-
setUpdateCount(-1);
|
|
115
|
-
setDisabledAllButtons(true);
|
|
116
|
-
let count = await request(`/${pluginId}/count-update`, {method: 'GET'});
|
|
117
|
-
setUpdateCount(count);
|
|
118
|
-
setDisabledAllButtons(false);
|
|
119
|
-
}
|
|
120
|
-
const updateMedia = async () => {
|
|
121
|
-
setDisplayUpdateResult(false);
|
|
122
|
-
setDisabledAllButtons(true);
|
|
123
|
-
|
|
124
|
-
let result = await request(`/${pluginId}/update-media`, {method: 'PUT'});
|
|
125
|
-
|
|
126
|
-
if (result.response === false)
|
|
127
|
-
{
|
|
128
|
-
setUpdateMessage('Image optimization was not successful. Please try again later.');
|
|
129
|
-
}
|
|
130
|
-
else
|
|
131
|
-
{
|
|
132
|
-
setUpdateMessage(`${result.response} image optimizations were successful.`);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
setDisplayUpdateResult(true);
|
|
136
|
-
setDisabledAllButtons(false);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return (
|
|
140
|
-
<>
|
|
141
|
-
<Stack spacing={4} padding={3}>
|
|
142
|
-
{success && isV7CheckSuccessful && (
|
|
143
|
-
<Alert title="Successful" onClose={() => setSuccess(false)} closeLabel="Close alert" variant={'success'}>
|
|
144
|
-
Configuration updated. Your domain is {isV7 ? '' : 'not'} of Cloudimage version 7.
|
|
145
|
-
</Alert>
|
|
146
|
-
)}
|
|
147
|
-
{success && !isV7CheckSuccessful && (
|
|
148
|
-
<Alert title="Failed" onClose={() => setError(false)} closeLabel="Close alert" variant={'danger'}>
|
|
149
|
-
Cannot auto-determine whether it's Cloudimage version 7 or not. Please mannually set Cloudimage version.
|
|
150
|
-
</Alert>
|
|
151
|
-
)}
|
|
152
|
-
{error && (
|
|
153
|
-
<Alert title="Failed" onClose={() => setError(false)} closeLabel="Close alert" variant={'danger'}>
|
|
154
|
-
Please check your configuration inputs. Ensure you entered valid inputs for all required fields.
|
|
155
|
-
</Alert>
|
|
156
|
-
)}
|
|
157
|
-
{updateCount > -1 && (
|
|
158
|
-
<Alert onClose={() => setUpdateCount(-1)} closeLabel="Close alert" variant={'success'}>
|
|
159
|
-
There are {updateCount} image URLs to be optimized.
|
|
160
|
-
</Alert>
|
|
161
|
-
)}
|
|
162
|
-
{displayUpdateResult && (
|
|
163
|
-
<Alert onClose={() => setDisplayUpdateResult(false)} closeLabel="Close alert" variant={'success'}>
|
|
164
|
-
{(updateCount <= 0) ? 'None are to be optimized.' : updateMessage}
|
|
165
|
-
</Alert>
|
|
166
|
-
)}
|
|
167
|
-
<Box paddingTop={5} paddingRight={8}>
|
|
168
|
-
<Typography variant={'alpha'}>Cloudimage by Scaleflex</Typography>
|
|
169
|
-
</Box>
|
|
170
|
-
<Field name="domain">
|
|
171
|
-
<Stack spacing={1}>
|
|
172
|
-
<FieldLabel>Token or Domain *</FieldLabel>
|
|
173
|
-
<FieldInput type="text" placeholder="Token/Domain" value={domain} onChange={(e) => {
|
|
174
|
-
setDomain(e.target.value)
|
|
175
|
-
}}/>
|
|
176
|
-
</Stack>
|
|
177
|
-
</Field>
|
|
178
|
-
{!isV7CheckSuccessful && (
|
|
179
|
-
<Stack spacing={1}>
|
|
180
|
-
<FieldLabel>Is Cloudimage version 7 ?</FieldLabel>
|
|
181
|
-
<RadioGroup onChange={e => setManualV7(e.target.value)} value={manualV7} name="manualV7">
|
|
182
|
-
<Radio value="true">Version 7</Radio>
|
|
183
|
-
<Radio value="false">Not version 7</Radio>
|
|
184
|
-
</RadioGroup>
|
|
185
|
-
</Stack>
|
|
186
|
-
)}
|
|
187
|
-
<Box width={200}>
|
|
188
|
-
<Button disabled={disabledAllButtons} onClick={() => saveConfiguration()}>Save configuration</Button>
|
|
189
|
-
</Box>
|
|
190
|
-
<Stack horizontal spacing={4}>
|
|
191
|
-
<Button disabled={disabledAllButtons || disableUpdateButtons} onClick={() => countUpdate()}>Count optimizable images</Button>
|
|
192
|
-
<Button disabled={disabledAllButtons || disableUpdateButtons} onClick={() => updateMedia()}>Optimize old images</Button>
|
|
193
|
-
</Stack>
|
|
194
|
-
</Stack>
|
|
195
|
-
</>
|
|
196
|
-
)
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
export default memo(HomePage);
|
package/admin/src/pluginId.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* axios with a custom config.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import axios from 'axios';
|
|
6
|
-
import { auth } from '@strapi/helper-plugin';
|
|
7
|
-
|
|
8
|
-
const instance = axios.create({
|
|
9
|
-
baseURL: process.env.STRAPI_ADMIN_BACKEND_URL,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
instance.interceptors.request.use(
|
|
13
|
-
async config => {
|
|
14
|
-
config.headers = {
|
|
15
|
-
Authorization: `Bearer ${auth.getToken()}`,
|
|
16
|
-
Accept: 'application/json',
|
|
17
|
-
'Content-Type': 'application/json',
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return config;
|
|
21
|
-
},
|
|
22
|
-
error => {
|
|
23
|
-
Promise.reject(error);
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
instance.interceptors.response.use(
|
|
28
|
-
response => response,
|
|
29
|
-
error => {
|
|
30
|
-
// whatever you want to do with the error
|
|
31
|
-
if (error.response?.status === 401) {
|
|
32
|
-
auth.clearAppStorage();
|
|
33
|
-
window.location.reload();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
export default instance;
|
package/server/bootstrap.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = ({ strapi }) => {
|
|
4
|
-
strapi.store({
|
|
5
|
-
environment: strapi.config.environment,
|
|
6
|
-
type: 'plugin',
|
|
7
|
-
name: 'cloudimage',
|
|
8
|
-
})
|
|
9
|
-
.get({key: 'options'})
|
|
10
|
-
.then((config) => {
|
|
11
|
-
if (config && config.hasOwnProperty('domain') && config.domain)
|
|
12
|
-
{
|
|
13
|
-
for (let index = 1; index < strapi.config.middlewares.length; index++)
|
|
14
|
-
{
|
|
15
|
-
let item = strapi.config.middlewares[index];
|
|
16
|
-
|
|
17
|
-
if (typeof item === 'object' && item.name === 'strapi::security' && !item.config.contentSecurityPolicy.directives['img-src'].includes(config.domain))
|
|
18
|
-
{
|
|
19
|
-
strapi.config.middlewares[index].config.contentSecurityPolicy.directives['img-src'].push(config.domain);
|
|
20
|
-
strapi.config.middlewares[index].config.contentSecurityPolicy.directives['media-src'].push(config.domain);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
};
|
package/server/config/index.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = ({ strapi }) => ({
|
|
4
|
-
async index(ctx) {
|
|
5
|
-
ctx.body = await strapi
|
|
6
|
-
.plugin('cloudimage-by-scaleflex')
|
|
7
|
-
.service('scaleflexCloudimage')
|
|
8
|
-
.getWelcomeMessage();
|
|
9
|
-
},
|
|
10
|
-
async getConfig(ctx) {
|
|
11
|
-
ctx.body = await strapi
|
|
12
|
-
.plugin('cloudimage-by-scaleflex')
|
|
13
|
-
.service('scaleflexCloudimage')
|
|
14
|
-
.getConfig();
|
|
15
|
-
},
|
|
16
|
-
async updateConfig(ctx) {
|
|
17
|
-
ctx.body = await strapi
|
|
18
|
-
.plugin('cloudimage-by-scaleflex')
|
|
19
|
-
.service('scaleflexCloudimage')
|
|
20
|
-
.updateConfig(ctx);
|
|
21
|
-
},
|
|
22
|
-
async checkV7(ctx) {
|
|
23
|
-
ctx.body = await strapi
|
|
24
|
-
.plugin('cloudimage-by-scaleflex')
|
|
25
|
-
.service('scaleflexCloudimage')
|
|
26
|
-
.checkV7(ctx);
|
|
27
|
-
},
|
|
28
|
-
async countUpdate(ctx) {
|
|
29
|
-
ctx.body = await strapi
|
|
30
|
-
.plugin('cloudimage-by-scaleflex')
|
|
31
|
-
.service('scaleflexCloudimage')
|
|
32
|
-
.countUpdate(ctx);
|
|
33
|
-
},
|
|
34
|
-
async updateMedia(ctx) {
|
|
35
|
-
ctx.body = await strapi
|
|
36
|
-
.plugin('cloudimage-by-scaleflex')
|
|
37
|
-
.service('scaleflexCloudimage')
|
|
38
|
-
.updateMedia(ctx);
|
|
39
|
-
},
|
|
40
|
-
});
|
package/server/destroy.js
DELETED
package/server/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const register = require('./register');
|
|
4
|
-
const bootstrap = require('./bootstrap');
|
|
5
|
-
const destroy = require('./destroy');
|
|
6
|
-
const config = require('./config');
|
|
7
|
-
const contentTypes = require('./content-types');
|
|
8
|
-
const controllers = require('./controllers');
|
|
9
|
-
const routes = require('./routes');
|
|
10
|
-
const middlewares = require('./middlewares');
|
|
11
|
-
const policies = require('./policies');
|
|
12
|
-
const services = require('./services');
|
|
13
|
-
|
|
14
|
-
module.exports = {
|
|
15
|
-
register,
|
|
16
|
-
bootstrap,
|
|
17
|
-
destroy,
|
|
18
|
-
config,
|
|
19
|
-
controllers,
|
|
20
|
-
routes,
|
|
21
|
-
services,
|
|
22
|
-
contentTypes,
|
|
23
|
-
policies,
|
|
24
|
-
middlewares,
|
|
25
|
-
};
|
package/server/policies/index.js
DELETED
package/server/register.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = ({ strapi }) => {
|
|
4
|
-
const pluginMiddleware = {
|
|
5
|
-
name: 'strapi::security',
|
|
6
|
-
config: {
|
|
7
|
-
contentSecurityPolicy: {
|
|
8
|
-
useDefaults: true,
|
|
9
|
-
directives: {
|
|
10
|
-
'connect-src': ["'self'", 'https:'],
|
|
11
|
-
'img-src': ["'self'", 'data:', 'blob:', 'scaleflex.cloudimg.io', 'assets.scaleflex.com', '*.cloudimg.io'],
|
|
12
|
-
'media-src': ["'self'", 'data:', 'blob:', 'scaleflex.cloudimg.io', 'assets.scaleflex.com', '*.cloudimg.io'],
|
|
13
|
-
upgradeInsecureRequests: null,
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// Merge a `source` object to a `target` recursively
|
|
20
|
-
const merge = (target, source) => {
|
|
21
|
-
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties
|
|
22
|
-
for (const key of Object.keys(source))
|
|
23
|
-
{
|
|
24
|
-
if (Array.isArray(source[key]))
|
|
25
|
-
{
|
|
26
|
-
Object.assign(source[key], [...new Set(target[key].concat(source[key]))]);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (source[key] instanceof Object && !Array.isArray(source[key]))
|
|
30
|
-
{
|
|
31
|
-
Object.assign(source[key], merge(target[key], source[key]));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Join `target` and modified `source`
|
|
36
|
-
Object.assign(target || {}, source);
|
|
37
|
-
|
|
38
|
-
return target;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
for (let index = 1; index < strapi.config.middlewares.length; index++)
|
|
42
|
-
{
|
|
43
|
-
let item = strapi.config.middlewares[index];
|
|
44
|
-
|
|
45
|
-
if (typeof item === 'object' && item.name === 'strapi::security')
|
|
46
|
-
{
|
|
47
|
-
let mergedSettings = merge(item.config, pluginMiddleware.config);
|
|
48
|
-
strapi.config.middlewares.splice(index, 1, {name: 'strapi::security', config: mergedSettings});
|
|
49
|
-
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
else if (typeof item === 'string' && item === 'strapi::security')
|
|
53
|
-
{
|
|
54
|
-
strapi.config.middlewares.splice(index, 1, pluginMiddleware);
|
|
55
|
-
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
else
|
|
59
|
-
{
|
|
60
|
-
strapi.config.middlewares.push(pluginMiddleware);
|
|
61
|
-
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
package/server/routes/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
module.exports = [
|
|
2
|
-
{
|
|
3
|
-
method: 'GET',
|
|
4
|
-
path: '/',
|
|
5
|
-
handler: 'scaleflexCloudimage.index',
|
|
6
|
-
config: {
|
|
7
|
-
policies: [],
|
|
8
|
-
auth: false,
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
method: 'GET',
|
|
13
|
-
path: '/config',
|
|
14
|
-
handler: 'scaleflexCloudimage.getConfig',
|
|
15
|
-
config: {
|
|
16
|
-
policies: [],
|
|
17
|
-
auth: false,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
method: 'PUT',
|
|
22
|
-
path: '/update-config',
|
|
23
|
-
handler: 'scaleflexCloudimage.updateConfig',
|
|
24
|
-
config: {
|
|
25
|
-
policies: [],
|
|
26
|
-
auth: false,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
method: 'GET',
|
|
31
|
-
path: '/is-v7',
|
|
32
|
-
handler: 'scaleflexCloudimage.checkV7',
|
|
33
|
-
config: {
|
|
34
|
-
policies: [],
|
|
35
|
-
auth: false,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
method: 'GET',
|
|
40
|
-
path: '/count-update',
|
|
41
|
-
handler: 'scaleflexCloudimage.countUpdate',
|
|
42
|
-
config: {
|
|
43
|
-
policies: [],
|
|
44
|
-
auth: false,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
method: 'PUT',
|
|
49
|
-
path: '/update-media',
|
|
50
|
-
handler: 'scaleflexCloudimage.updateMedia',
|
|
51
|
-
config: {
|
|
52
|
-
policies: [],
|
|
53
|
-
auth: false,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
];
|