UNPKG

apitally

Version:

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

79 lines 2.81 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); var configure_exports = {}; __export(configure_exports, { configure: () => configure }); module.exports = __toCommonJS(configure_exports); const import_meta = {}; var import_node_url = require("node:url"); var import_paramValidation = require("../common/paramValidation.js"); const STUBS_ROOT = (0, import_node_url.fileURLToPath)(new URL("./stubs/", import_meta.url)); async function configure(command) { const clientId = await command.prompt.ask("Apitally client ID", { result(value) { return value.trim().toLowerCase(); }, validate(value) { return (0, import_paramValidation.isValidClientId)(value); } }); const env = await command.prompt.ask("Environment name", { default: "dev", result(value) { return value.trim().toLowerCase().replaceAll("_", "-").replaceAll(" ", "-"); }, validate(value) { return (0, import_paramValidation.isValidEnv)(value); } }); const enableRequestLogging = await command.prompt.confirm("Enable request logging?", { default: false }); const codemods = await command.createCodemods(); await codemods.makeUsingStub(STUBS_ROOT, "config/apitally.stub", { enableRequestLogging }); await codemods.registerMiddleware("router", [ { path: "apitally/adonisjs/middleware" } ]); await codemods.updateRcFile((rcFile) => { rcFile.addProvider("apitally/adonisjs/provider"); }); await codemods.defineEnvVariables({ APITALLY_CLIENT_ID: clientId, APITALLY_ENV: env }); await codemods.defineEnvValidations({ leadingComment: "Variables for configuring the apitally package", variables: { APITALLY_CLIENT_ID: "Env.schema.string()", APITALLY_ENV: "Env.schema.string.optional()" } }); } __name(configure, "configure"); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { configure }); //# sourceMappingURL=configure.cjs.map