@strapi/plugin-documentation 4.0.0-next.9 → 4.0.0
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/admin/src/components/FieldActionWrapper/index.js +14 -0
- package/admin/src/components/PluginIcon/index.js +12 -0
- package/admin/src/index.js +23 -11
- package/admin/src/pages/PluginPage/index.js +199 -0
- package/admin/src/pages/PluginPage/tests/index.test.js +873 -0
- package/admin/src/pages/PluginPage/tests/server.js +23 -0
- package/admin/src/pages/SettingsPage/index.js +181 -0
- package/admin/src/pages/SettingsPage/tests/index.test.js +612 -0
- package/admin/src/pages/SettingsPage/tests/server.js +18 -0
- package/admin/src/pages/{HomePage/utils → utils}/api.js +5 -4
- package/admin/src/pages/{HomePage/utils → utils}/schema.js +0 -0
- package/admin/src/pages/utils/useReactQuery.js +46 -0
- package/admin/src/translations/ar.json +0 -3
- package/admin/src/translations/cs.json +0 -3
- package/admin/src/translations/de.json +0 -3
- package/admin/src/translations/en.json +14 -3
- package/admin/src/translations/es.json +0 -3
- package/admin/src/translations/fr.json +0 -3
- package/admin/src/translations/id.json +0 -3
- package/admin/src/translations/it.json +0 -3
- package/admin/src/translations/ko.json +0 -3
- package/admin/src/translations/ms.json +0 -3
- package/admin/src/translations/nl.json +0 -3
- package/admin/src/translations/pl.json +0 -3
- package/admin/src/translations/pt-BR.json +0 -3
- package/admin/src/translations/pt.json +0 -3
- package/admin/src/translations/ru.json +0 -3
- package/admin/src/translations/sk.json +0 -3
- package/admin/src/translations/th.json +0 -3
- package/admin/src/translations/tr.json +0 -3
- package/admin/src/translations/uk.json +0 -3
- package/admin/src/translations/vi.json +0 -3
- package/admin/src/translations/zh-Hans.json +3 -6
- package/admin/src/translations/zh.json +0 -3
- package/package.json +32 -47
- package/server/bootstrap.js +19 -105
- package/server/config/default-config.js +12 -15
- package/server/config/index.js +10 -2
- package/server/controllers/documentation.js +61 -127
- package/server/index.js +17 -0
- package/server/middlewares/documentation.js +18 -41
- package/server/{policies/index-policy.js → middlewares/restrict-access.js} +5 -16
- package/{public → server/public}/index.html +0 -0
- package/{public → server/public}/login.html +0 -0
- package/server/register.js +11 -0
- package/server/routes/index.js +18 -25
- package/server/services/documentation.js +125 -1835
- package/server/utils/builders/build-api-endpoint-path.js +174 -0
- package/server/utils/builders/build-api-requests.js +41 -0
- package/server/utils/builders/build-api-responses.js +108 -0
- package/server/utils/builders/index.js +11 -0
- package/server/utils/clean-schema-attributes.js +205 -0
- package/server/utils/error-response.js +22 -0
- package/server/utils/get-schema-data.js +32 -0
- package/server/utils/query-params.js +84 -0
- package/strapi-admin.js +3 -0
- package/strapi-server.js +1 -19
- package/admin/src/assets/images/logo.svg +0 -1
- package/admin/src/components/Block/components.js +0 -26
- package/admin/src/components/Block/index.js +0 -39
- package/admin/src/components/Copy/index.js +0 -36
- package/admin/src/components/Header/index.js +0 -72
- package/admin/src/components/Row/ButtonContainer.js +0 -67
- package/admin/src/components/Row/components.js +0 -83
- package/admin/src/components/Row/index.js +0 -51
- package/admin/src/pages/App/index.js +0 -21
- package/admin/src/pages/HomePage/components.js +0 -59
- package/admin/src/pages/HomePage/index.js +0 -175
- package/admin/src/pages/HomePage/useHomePage.js +0 -56
- package/server/policies/index.js +0 -7
- package/server/services/utils/forms.json +0 -29
|
@@ -8,25 +8,25 @@
|
|
|
8
8
|
|
|
9
9
|
// Core dependencies.
|
|
10
10
|
const path = require('path');
|
|
11
|
+
const bcrypt = require('bcryptjs');
|
|
11
12
|
|
|
12
13
|
// Public dependencies.
|
|
13
14
|
const fs = require('fs-extra');
|
|
14
|
-
const cheerio = require('cheerio');
|
|
15
15
|
const _ = require('lodash');
|
|
16
16
|
const koaStatic = require('koa-static');
|
|
17
17
|
|
|
18
18
|
module.exports = {
|
|
19
|
-
|
|
19
|
+
async getInfos(ctx) {
|
|
20
20
|
try {
|
|
21
|
-
const
|
|
22
|
-
const docVersions =
|
|
23
|
-
const
|
|
21
|
+
const docService = strapi.plugin('documentation').service('documentation');
|
|
22
|
+
const docVersions = docService.getDocumentationVersions();
|
|
23
|
+
const documentationAccess = await docService.getDocumentationAccess();
|
|
24
24
|
|
|
25
25
|
ctx.send({
|
|
26
26
|
docVersions,
|
|
27
|
-
currentVersion:
|
|
28
|
-
prefix: strapi.
|
|
29
|
-
|
|
27
|
+
currentVersion: docService.getDocumentationVersion(),
|
|
28
|
+
prefix: strapi.plugin('documentation').config('x-strapi-config').path,
|
|
29
|
+
documentationAccess,
|
|
30
30
|
});
|
|
31
31
|
} catch (err) {
|
|
32
32
|
ctx.badRequest(null, err.message);
|
|
@@ -43,10 +43,13 @@ module.exports = {
|
|
|
43
43
|
const version =
|
|
44
44
|
major && minor && patch
|
|
45
45
|
? `${major}.${minor}.${patch}`
|
|
46
|
-
: strapi
|
|
46
|
+
: strapi
|
|
47
|
+
.plugin('documentation')
|
|
48
|
+
.service('documentation')
|
|
49
|
+
.getDocumentationVersion();
|
|
50
|
+
|
|
47
51
|
const openAPISpecsPath = path.join(
|
|
48
|
-
strapi.
|
|
49
|
-
'extensions',
|
|
52
|
+
strapi.dirs.extensions,
|
|
50
53
|
'documentation',
|
|
51
54
|
'documentation',
|
|
52
55
|
version,
|
|
@@ -66,8 +69,7 @@ module.exports = {
|
|
|
66
69
|
|
|
67
70
|
try {
|
|
68
71
|
const layoutPath = path.resolve(
|
|
69
|
-
strapi.
|
|
70
|
-
'extensions',
|
|
72
|
+
strapi.dirs.extensions,
|
|
71
73
|
'documentation',
|
|
72
74
|
'public',
|
|
73
75
|
'index.html'
|
|
@@ -79,13 +81,8 @@ module.exports = {
|
|
|
79
81
|
ctx.url = path.basename(`${ctx.url}/index.html`);
|
|
80
82
|
|
|
81
83
|
try {
|
|
82
|
-
const staticFolder = path.resolve(
|
|
83
|
-
|
|
84
|
-
'extensions',
|
|
85
|
-
'documentation',
|
|
86
|
-
'public'
|
|
87
|
-
);
|
|
88
|
-
return await koaStatic(staticFolder)(ctx, next);
|
|
84
|
+
const staticFolder = path.resolve(strapi.dirs.extensions, 'documentation', 'public');
|
|
85
|
+
return koaStatic(staticFolder)(ctx, next);
|
|
89
86
|
} catch (e) {
|
|
90
87
|
strapi.log.error(e);
|
|
91
88
|
}
|
|
@@ -101,6 +98,9 @@ module.exports = {
|
|
|
101
98
|
},
|
|
102
99
|
|
|
103
100
|
async loginView(ctx, next) {
|
|
101
|
+
// lazy require cheerio
|
|
102
|
+
const cheerio = require('cheerio');
|
|
103
|
+
|
|
104
104
|
const { error } = ctx.query;
|
|
105
105
|
|
|
106
106
|
try {
|
|
@@ -116,8 +116,7 @@ module.exports = {
|
|
|
116
116
|
|
|
117
117
|
try {
|
|
118
118
|
const layoutPath = path.resolve(
|
|
119
|
-
strapi.
|
|
120
|
-
'extensions',
|
|
119
|
+
strapi.dirs.extensions,
|
|
121
120
|
'documentation',
|
|
122
121
|
'public',
|
|
123
122
|
'login.html'
|
|
@@ -128,13 +127,8 @@ module.exports = {
|
|
|
128
127
|
ctx.url = path.basename(`${ctx.url}/login.html`);
|
|
129
128
|
|
|
130
129
|
try {
|
|
131
|
-
const staticFolder = path.resolve(
|
|
132
|
-
|
|
133
|
-
'extensions',
|
|
134
|
-
'documentation',
|
|
135
|
-
'public'
|
|
136
|
-
);
|
|
137
|
-
return await koaStatic(staticFolder)(ctx, next);
|
|
130
|
+
const staticFolder = path.resolve(strapi.dirs.extensions, 'documentation', 'public');
|
|
131
|
+
return koaStatic(staticFolder)(ctx, next);
|
|
138
132
|
} catch (e) {
|
|
139
133
|
strapi.log.error(e);
|
|
140
134
|
}
|
|
@@ -151,23 +145,19 @@ module.exports = {
|
|
|
151
145
|
body: { password },
|
|
152
146
|
} = ctx.request;
|
|
153
147
|
|
|
154
|
-
const { password:
|
|
155
|
-
.store({
|
|
156
|
-
environment: '',
|
|
157
|
-
type: 'plugin',
|
|
158
|
-
name: 'documentation',
|
|
159
|
-
key: 'config',
|
|
160
|
-
})
|
|
148
|
+
const { password: hash } = await strapi
|
|
149
|
+
.store({ type: 'plugin', name: 'documentation', key: 'config' })
|
|
161
150
|
.get();
|
|
162
151
|
|
|
163
|
-
const isValid = await
|
|
164
|
-
|
|
165
|
-
storedPassword
|
|
166
|
-
);
|
|
152
|
+
const isValid = await bcrypt.compare(password, hash);
|
|
153
|
+
|
|
167
154
|
let querystring = '?error=password';
|
|
168
155
|
|
|
169
156
|
if (isValid) {
|
|
170
|
-
ctx.session.documentation =
|
|
157
|
+
ctx.session.documentation = {
|
|
158
|
+
logged: true,
|
|
159
|
+
};
|
|
160
|
+
|
|
171
161
|
querystring = '';
|
|
172
162
|
}
|
|
173
163
|
|
|
@@ -178,128 +168,72 @@ module.exports = {
|
|
|
178
168
|
);
|
|
179
169
|
},
|
|
180
170
|
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
admin,
|
|
188
|
-
},
|
|
189
|
-
} = ctx;
|
|
171
|
+
async regenerateDoc(ctx) {
|
|
172
|
+
const { version } = ctx.request.body;
|
|
173
|
+
|
|
174
|
+
const service = strapi.service('plugin::documentation.documentation');
|
|
175
|
+
|
|
176
|
+
const documentationVersions = service.getDocumentationVersions().map(el => el.version);
|
|
190
177
|
|
|
191
178
|
if (_.isEmpty(version)) {
|
|
192
|
-
return ctx.badRequest(
|
|
193
|
-
null,
|
|
194
|
-
admin ? 'documentation.error.noVersion' : 'Please provide a version.'
|
|
195
|
-
);
|
|
179
|
+
return ctx.badRequest('Please provide a version.');
|
|
196
180
|
}
|
|
197
181
|
|
|
198
182
|
if (!documentationVersions.includes(version)) {
|
|
199
|
-
return ctx.badRequest(
|
|
200
|
-
null,
|
|
201
|
-
admin
|
|
202
|
-
? 'documentation.error.regenerateDoc.versionMissing'
|
|
203
|
-
: 'The version you are trying to generate does not exist.'
|
|
204
|
-
);
|
|
183
|
+
return ctx.badRequest('The version you are trying to generate does not exist.');
|
|
205
184
|
}
|
|
206
185
|
|
|
207
186
|
try {
|
|
208
187
|
strapi.reload.isWatching = false;
|
|
209
|
-
|
|
210
|
-
const documentationPath = service.getMergedDocumentationPath(version);
|
|
211
|
-
// Write the file
|
|
212
|
-
fs.writeFileSync(
|
|
213
|
-
path.resolve(documentationPath, 'full_documentation.json'),
|
|
214
|
-
JSON.stringify(fullDoc, null, 2),
|
|
215
|
-
'utf8'
|
|
216
|
-
);
|
|
188
|
+
await service.generateFullDoc(version);
|
|
217
189
|
ctx.send({ ok: true });
|
|
218
|
-
} catch (err) {
|
|
219
|
-
ctx.badRequest(null, admin ? 'documentation.error.regenerateDoc' : 'An error occured');
|
|
220
190
|
} finally {
|
|
221
191
|
strapi.reload.isWatching = true;
|
|
222
192
|
}
|
|
223
193
|
},
|
|
224
194
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const service = strapi.plugins.documentation.services.documentation;
|
|
228
|
-
const documentationVersions = service.retrieveDocumentationVersions().map(el => el.version);
|
|
195
|
+
async deleteDoc(ctx) {
|
|
196
|
+
const { version } = ctx.params;
|
|
229
197
|
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
} = ctx;
|
|
198
|
+
const service = strapi.service('plugin::documentation.documentation');
|
|
199
|
+
|
|
200
|
+
const documentationVersions = service.getDocumentationVersions().map(el => el.version);
|
|
234
201
|
|
|
235
202
|
if (_.isEmpty(version)) {
|
|
236
|
-
return ctx.badRequest(
|
|
237
|
-
null,
|
|
238
|
-
admin ? 'documentation.error.noVersion' : 'Please provide a version.'
|
|
239
|
-
);
|
|
203
|
+
return ctx.badRequest('Please provide a version.');
|
|
240
204
|
}
|
|
241
205
|
|
|
242
206
|
if (!documentationVersions.includes(version)) {
|
|
243
|
-
return ctx.badRequest(
|
|
244
|
-
null,
|
|
245
|
-
admin
|
|
246
|
-
? 'documentation.error.deleteDoc.versionMissing'
|
|
247
|
-
: 'The version you are trying to delete does not exist.'
|
|
248
|
-
);
|
|
207
|
+
return ctx.badRequest('The version you are trying to delete does not exist.');
|
|
249
208
|
}
|
|
250
209
|
|
|
251
210
|
try {
|
|
211
|
+
strapi.reload.isWatching = false;
|
|
252
212
|
await service.deleteDocumentation(version);
|
|
253
213
|
ctx.send({ ok: true });
|
|
254
|
-
} catch (err) {
|
|
255
|
-
ctx.badRequest(null, admin ? 'notification.error' : err.message);
|
|
256
214
|
} finally {
|
|
257
215
|
strapi.reload.isWatching = true;
|
|
258
216
|
}
|
|
259
217
|
},
|
|
260
218
|
|
|
261
|
-
|
|
262
|
-
const {
|
|
263
|
-
admin,
|
|
264
|
-
body: { restrictedAccess, password },
|
|
265
|
-
} = ctx.request;
|
|
266
|
-
const usersPermService = strapi.plugins['users-permissions'].services;
|
|
267
|
-
const pluginStore = strapi.store({
|
|
268
|
-
environment: '',
|
|
269
|
-
type: 'plugin',
|
|
270
|
-
name: 'documentation',
|
|
271
|
-
});
|
|
272
|
-
const prevConfig = await pluginStore.get({ key: 'config' });
|
|
273
|
-
|
|
274
|
-
if (restrictedAccess && _.isEmpty(password)) {
|
|
275
|
-
return ctx.badRequest(
|
|
276
|
-
null,
|
|
277
|
-
admin ? 'users-permissions.Auth.form.error.password.provide' : 'Please provide a password'
|
|
278
|
-
);
|
|
279
|
-
}
|
|
219
|
+
async updateSettings(ctx) {
|
|
220
|
+
const { restrictedAccess, password } = ctx.request.body;
|
|
280
221
|
|
|
281
|
-
const
|
|
222
|
+
const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });
|
|
282
223
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return ctx.badRequest(
|
|
287
|
-
null,
|
|
288
|
-
admin
|
|
289
|
-
? 'users-permissions.Auth.form.error.password.format'
|
|
290
|
-
: 'our password cannot contain more than three times the symbol `$`.'
|
|
291
|
-
);
|
|
292
|
-
}
|
|
224
|
+
const config = {
|
|
225
|
+
restrictedAccess: Boolean(restrictedAccess),
|
|
226
|
+
};
|
|
293
227
|
|
|
294
|
-
if (
|
|
295
|
-
|
|
296
|
-
password
|
|
297
|
-
}
|
|
298
|
-
}
|
|
228
|
+
if (restrictedAccess) {
|
|
229
|
+
if (_.isEmpty(password)) {
|
|
230
|
+
return ctx.badRequest('Please provide a password');
|
|
231
|
+
}
|
|
299
232
|
|
|
300
|
-
|
|
233
|
+
config.password = await bcrypt.hash(password, 10);
|
|
234
|
+
}
|
|
301
235
|
|
|
302
|
-
await pluginStore.set({ key: 'config', value:
|
|
236
|
+
await pluginStore.set({ key: 'config', value: config });
|
|
303
237
|
|
|
304
238
|
return ctx.send({ ok: true });
|
|
305
239
|
},
|
package/server/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const bootstrap = require('./bootstrap');
|
|
4
|
+
const services = require('./services');
|
|
5
|
+
const routes = require('./routes');
|
|
6
|
+
const controllers = require('./controllers');
|
|
7
|
+
const register = require('./register');
|
|
8
|
+
const config = require('./config');
|
|
9
|
+
|
|
10
|
+
module.exports = () => ({
|
|
11
|
+
bootstrap,
|
|
12
|
+
config,
|
|
13
|
+
routes,
|
|
14
|
+
controllers,
|
|
15
|
+
register,
|
|
16
|
+
services,
|
|
17
|
+
});
|
|
@@ -1,53 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
|
-
const _ = require('lodash');
|
|
5
|
-
const swaggerUi = require('swagger-ui-dist');
|
|
6
4
|
const koaStatic = require('koa-static');
|
|
5
|
+
const session = require('koa-session');
|
|
6
|
+
const swaggerUi = require('swagger-ui-dist');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
load: {
|
|
13
|
-
beforeInitialize() {
|
|
14
|
-
strapi.config.middleware.load.before.push('documentation');
|
|
15
|
-
|
|
16
|
-
initialRoutes.push(..._.cloneDeep(strapi.plugins.documentation.routes));
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
initialize() {
|
|
20
|
-
// Find the plugins routes.
|
|
21
|
-
strapi.plugins.documentation.routes = strapi.plugins.documentation.routes.map(
|
|
22
|
-
(route, index) => {
|
|
23
|
-
if (route.handler === 'Documentation.getInfos') {
|
|
24
|
-
return route;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (route.handler === 'Documentation.index' || route.path === '/login') {
|
|
28
|
-
route.config.policies = initialRoutes[index].config.policies;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Set prefix to empty to be able to customise it.
|
|
32
|
-
if (strapi.config.has('plugins.documentation.x-strapi-config.path')) {
|
|
33
|
-
route.config.prefix = '';
|
|
34
|
-
route.path = `/${strapi.config.get('plugin.documentation.x-strapi-config').path}${
|
|
35
|
-
route.path
|
|
36
|
-
}`.replace('//', '/');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return route;
|
|
40
|
-
}
|
|
41
|
-
);
|
|
8
|
+
module.exports = async ({ strapi }) => {
|
|
9
|
+
const sessionConfig = strapi.config.get('plugin.documentation').session;
|
|
10
|
+
strapi.server.app.keys = sessionConfig.secretKeys;
|
|
11
|
+
strapi.server.app.use(session(sessionConfig, strapi.server.app));
|
|
42
12
|
|
|
43
|
-
|
|
13
|
+
strapi.server.routes([
|
|
14
|
+
{
|
|
15
|
+
method: 'GET',
|
|
16
|
+
path: '/plugins/documentation/(.*)',
|
|
17
|
+
async handler(ctx, next) {
|
|
44
18
|
ctx.url = path.basename(ctx.url);
|
|
45
19
|
|
|
46
|
-
return
|
|
47
|
-
maxage:
|
|
20
|
+
return koaStatic(swaggerUi.getAbsoluteFSPath(), {
|
|
21
|
+
maxage: 86400000,
|
|
48
22
|
defer: true,
|
|
49
23
|
})(ctx, next);
|
|
50
|
-
}
|
|
24
|
+
},
|
|
25
|
+
config: {
|
|
26
|
+
auth: false,
|
|
27
|
+
},
|
|
51
28
|
},
|
|
52
|
-
|
|
29
|
+
]);
|
|
53
30
|
};
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
module.exports = async (ctx, next) => {
|
|
4
|
-
const pluginStore = strapi.store({
|
|
5
|
-
|
|
6
|
-
type: 'plugin',
|
|
7
|
-
name: 'documentation',
|
|
8
|
-
});
|
|
4
|
+
const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });
|
|
5
|
+
|
|
9
6
|
const config = await pluginStore.get({ key: 'config' });
|
|
10
7
|
|
|
11
8
|
if (!config.restrictedAccess) {
|
|
12
|
-
return
|
|
9
|
+
return next();
|
|
13
10
|
}
|
|
14
11
|
|
|
15
|
-
if (!ctx.session.documentation) {
|
|
12
|
+
if (!ctx.session.documentation || !ctx.session.documentation.logged) {
|
|
16
13
|
const querystring = ctx.querystring ? `?${ctx.querystring}` : '';
|
|
17
14
|
|
|
18
15
|
return ctx.redirect(
|
|
@@ -21,15 +18,7 @@ module.exports = async (ctx, next) => {
|
|
|
21
18
|
}/login${querystring}`
|
|
22
19
|
);
|
|
23
20
|
}
|
|
24
|
-
const isValid = await strapi.plugins['users-permissions'].services.user.validatePassword(
|
|
25
|
-
ctx.session.documentation,
|
|
26
|
-
config.password
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
if (!isValid) {
|
|
30
|
-
ctx.session.documentation = null;
|
|
31
|
-
}
|
|
32
21
|
|
|
33
22
|
// Execute the action.
|
|
34
|
-
|
|
23
|
+
return next();
|
|
35
24
|
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const registerDocumentationMiddleWare = require('./middlewares/documentation');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Register upload plugin
|
|
7
|
+
* @param {{ strapi: import('@strapi/strapi').Strapi }}
|
|
8
|
+
*/
|
|
9
|
+
module.exports = async ({ strapi }) => {
|
|
10
|
+
await registerDocumentationMiddleWare({ strapi });
|
|
11
|
+
};
|
package/server/routes/index.js
CHANGED
|
@@ -1,67 +1,60 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
const restrictAccess = require('../middlewares/restrict-access');
|
|
2
3
|
|
|
3
4
|
module.exports = [
|
|
4
5
|
{
|
|
5
6
|
method: 'GET',
|
|
6
7
|
path: '/',
|
|
7
|
-
handler: '
|
|
8
|
+
handler: 'documentation.index',
|
|
8
9
|
config: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{ name: 'admin::hasPermissions', options: { actions: ['plugin::documentation.read'] } },
|
|
12
|
-
],
|
|
10
|
+
auth: false,
|
|
11
|
+
middlewares: [restrictAccess],
|
|
13
12
|
},
|
|
14
13
|
},
|
|
15
14
|
{
|
|
16
15
|
method: 'GET',
|
|
17
16
|
path: '/v:major(\\d+).:minor(\\d+).:patch(\\d+)',
|
|
18
|
-
handler: '
|
|
17
|
+
handler: 'documentation.index',
|
|
19
18
|
config: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{ name: 'admin::hasPermissions', options: { actions: ['plugin::documentation.read'] } },
|
|
23
|
-
],
|
|
19
|
+
auth: false,
|
|
20
|
+
middlewares: [restrictAccess],
|
|
24
21
|
},
|
|
25
22
|
},
|
|
26
23
|
{
|
|
27
24
|
method: 'GET',
|
|
28
25
|
path: '/login',
|
|
29
|
-
handler: '
|
|
26
|
+
handler: 'documentation.loginView',
|
|
30
27
|
config: {
|
|
31
|
-
|
|
32
|
-
{ name: 'admin::hasPermissions', options: { actions: ['plugin::documentation.read'] } },
|
|
33
|
-
],
|
|
28
|
+
auth: false,
|
|
34
29
|
},
|
|
35
30
|
},
|
|
36
31
|
{
|
|
37
32
|
method: 'POST',
|
|
38
33
|
path: '/login',
|
|
39
|
-
handler: '
|
|
34
|
+
handler: 'documentation.login',
|
|
40
35
|
config: {
|
|
41
|
-
|
|
42
|
-
{ name: 'admin::hasPermissions', options: { actions: ['plugin::documentation.read'] } },
|
|
43
|
-
],
|
|
36
|
+
auth: false,
|
|
44
37
|
},
|
|
45
38
|
},
|
|
46
39
|
{
|
|
47
40
|
method: 'GET',
|
|
48
41
|
path: '/getInfos',
|
|
49
|
-
handler: '
|
|
42
|
+
handler: 'documentation.getInfos',
|
|
50
43
|
config: {
|
|
51
44
|
policies: [
|
|
52
|
-
{ name: 'admin::hasPermissions',
|
|
45
|
+
{ name: 'admin::hasPermissions', config: { actions: ['plugin::documentation.read'] } },
|
|
53
46
|
],
|
|
54
47
|
},
|
|
55
48
|
},
|
|
56
49
|
{
|
|
57
50
|
method: 'POST',
|
|
58
51
|
path: '/regenerateDoc',
|
|
59
|
-
handler: '
|
|
52
|
+
handler: 'documentation.regenerateDoc',
|
|
60
53
|
config: {
|
|
61
54
|
policies: [
|
|
62
55
|
{
|
|
63
56
|
name: 'admin::hasPermissions',
|
|
64
|
-
|
|
57
|
+
config: { actions: ['plugin::documentation.settings.regenerate'] },
|
|
65
58
|
},
|
|
66
59
|
],
|
|
67
60
|
},
|
|
@@ -69,12 +62,12 @@ module.exports = [
|
|
|
69
62
|
{
|
|
70
63
|
method: 'PUT',
|
|
71
64
|
path: '/updateSettings',
|
|
72
|
-
handler: '
|
|
65
|
+
handler: 'documentation.updateSettings',
|
|
73
66
|
config: {
|
|
74
67
|
policies: [
|
|
75
68
|
{
|
|
76
69
|
name: 'admin::hasPermissions',
|
|
77
|
-
|
|
70
|
+
config: { actions: ['plugin::documentation.settings.update'] },
|
|
78
71
|
},
|
|
79
72
|
],
|
|
80
73
|
},
|
|
@@ -82,7 +75,7 @@ module.exports = [
|
|
|
82
75
|
{
|
|
83
76
|
method: 'DELETE',
|
|
84
77
|
path: '/deleteDoc/:version',
|
|
85
|
-
handler: '
|
|
78
|
+
handler: 'documentation.deleteDoc',
|
|
86
79
|
config: {
|
|
87
80
|
policies: [],
|
|
88
81
|
},
|