UNPKG

apitally

Version:

Simple API monitoring & analytics for REST APIs built with Express, Fastify, NestJS, AdonisJS, Hono, H3, Elysia, and Koa.

98 lines (95 loc) 2.69 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/h3/utils.ts var utils_exports = {}; __export(utils_exports, { getAppInfo: () => getAppInfo }); module.exports = __toCommonJS(utils_exports); // src/common/packageVersions.ts var import_node_module = require("module"); var import_meta = {}; function getPackageVersion(name) { const packageJsonPath = `${name}/package.json`; try { return require(packageJsonPath).version || null; } catch (error) { try { const _require = (0, import_node_module.createRequire)(import_meta.url); return _require(packageJsonPath).version || null; } catch (error2) { return null; } } } __name(getPackageVersion, "getPackageVersion"); // src/h3/utils.ts function getAppInfo(h3, appVersion) { const versions = []; if (process.versions.node) { versions.push([ "nodejs", process.versions.node ]); } if (process.versions.bun) { versions.push([ "bun", process.versions.bun ]); } const h3Version = getPackageVersion("h3"); const apitallyVersion = getPackageVersion("../.."); if (h3Version) { versions.push([ "h3", h3Version ]); } if (apitallyVersion) { versions.push([ "apitally", apitallyVersion ]); } if (appVersion) { versions.push([ "app", appVersion ]); } return { paths: h3._routes.map((route) => ({ method: route.method || "", path: route.route || "" })).filter((route) => route.method && route.path && ![ "HEAD", "OPTIONS" ].includes(route.method.toUpperCase())), versions: Object.fromEntries(versions), client: "js:h3" }; } __name(getAppInfo, "getAppInfo"); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { getAppInfo }); //# sourceMappingURL=utils.cjs.map