26 lines
548 B
JavaScript
Raw Normal View History

'use strict';
const path = require('path');
2019-06-08 18:50:07 +02:00
const koaStatic = require('koa-static');
2021-10-14 10:48:29 -04:00
const swaggerUi = require('swagger-ui-dist');
2021-10-05 11:39:02 -04:00
module.exports = async ({ strapi }) => {
strapi.server.routes([
{
method: 'GET',
path: '/plugins/documentation/(.*)',
async handler(ctx, next) {
ctx.url = path.basename(ctx.url);
return koaStatic(swaggerUi.getAbsoluteFSPath(), {
maxage: 86400000,
2021-10-05 11:39:02 -04:00
defer: true,
})(ctx, next);
},
config: {
auth: false,
},
2019-06-08 18:50:07 +02:00
},
2021-10-05 11:39:02 -04:00
]);
};