/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/plugins/documentation/server/src/middlewares/documentation.ts
25 строк
608 B
Alexandre Bodin
chore: migrate doc plugin to ts
21 мар 2024, 20:20
21 мар 2024, 20:20
eedd4c9
Код
Авторство
О чём код?
import path from 'path'; import koaStatic from 'koa-static'; import swaggerUi from 'swagger-ui-dist'; import type { Core } from '@strapi/types'; export const addDocumentMiddlewares = async ({ strapi }: { strapi: Core.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, defer: true, })(ctx, next); }, config: { auth: false, }, }, ]); };