文件操作 - openapi.mjs
返回文件管理
返回主菜单
删除本文件
文件: /var/www/OLD/node_modules/nitropack/dist/runtime/internal/routes/openapi.mjs
编辑文件内容
import { eventHandler, getRequestURL } from "h3"; import { joinURL } from "ufo"; import { handlersMeta } from "#nitro-internal-virtual/server-handlers-meta"; import { useRuntimeConfig } from "../config.mjs"; export default eventHandler((event) => { const runtimeConfig = useRuntimeConfig(event); const base = runtimeConfig.app?.baseURL; const url = joinURL(getRequestURL(event).origin, base); const meta = { title: "Nitro Server Routes", ...runtimeConfig.nitro?.openAPI?.meta }; return { openapi: "3.1.0", info: { title: meta?.title, version: meta?.version, description: meta?.description }, servers: [ { url, description: "Local Development Server", variables: {} } ], paths: getPaths() }; }); function getPaths() { const paths = {}; for (const h of handlersMeta) { const { route, parameters } = normalizeRoute(h.route || ""); const tags = defaultTags(h.route || ""); const method = (h.method || "get").toLowerCase(); const item = { [method]: { tags, parameters, responses: { 200: { description: "OK" } }, ...h.meta?.openAPI } }; if (paths[route] === void 0) { paths[route] = item; } else { Object.assign(paths[route], item); } } return paths; } function normalizeRoute(_route) { const parameters = []; let anonymousCtr = 0; const route = _route.replace(/:(\w+)/g, (_, name) => `{${name}}`).replace(/\/(\*)\//g, () => `/{param${++anonymousCtr}}/`).replace(/\*\*{/, "{").replace(/\/(\*\*)$/g, () => `/{*param${++anonymousCtr}}`); const paramMatches = route.matchAll(/{(\*?\w+)}/g); for (const match of paramMatches) { const name = match[1]; if (!parameters.some((p) => p.name === name)) { parameters.push({ name, in: "path", required: true, schema: { type: "string" } }); } } return { route, parameters }; } function defaultTags(route) { const tags = []; if (route.startsWith("/api/")) { tags.push("API Routes"); } else if (route.startsWith("/_")) { tags.push("Internal"); } else { tags.push("App Routes"); } return tags; }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件