mirror of
https://github.com/strapi/strapi.git
synced 2025-07-10 10:33:53 +00:00
31 lines
785 B
JavaScript
Executable File
31 lines
785 B
JavaScript
Executable File
'use strict';
|
|
|
|
const path = require('path');
|
|
const koaStatic = require('koa-static');
|
|
const session = require('koa-session');
|
|
const swaggerUi = require('swagger-ui-dist');
|
|
|
|
module.exports = async ({ strapi }) => {
|
|
const sessionConfig = strapi.config.get('plugin.documentation').session;
|
|
strapi.server.app.keys = sessionConfig.secretKeys;
|
|
strapi.server.app.use(session(sessionConfig, strapi.server.app));
|
|
|
|
strapi.server.routes([
|
|
{
|
|
method: 'GET',
|
|
path: '/plugins/documentation/(.*)',
|
|
async handler(ctx, next) {
|
|
ctx.url = path.basename(ctx.url);
|
|
|
|
return koaStatic(swaggerUi.getAbsoluteFSPath(), {
|
|
maxage: 86400000,
|
|
defer: true,
|
|
})(ctx, next);
|
|
},
|
|
config: {
|
|
auth: false,
|
|
},
|
|
},
|
|
]);
|
|
};
|