apitally
Version:
Simple API monitoring & analytics for REST APIs built with Express, Fastify, NestJS, AdonisJS, Hono, H3, Elysia, Hapi, and Koa.
55 lines • 1.73 kB
JavaScript
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
import { fileURLToPath } from "node:url";
import { isValidClientId, isValidEnv } from "../common/paramValidation.js";
const STUBS_ROOT = 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 isValidClientId(value);
}
});
const env = await command.prompt.ask("Environment name", {
default: "dev",
result(value) {
return value.trim().toLowerCase().replaceAll("_", "-").replaceAll(" ", "-");
},
validate(value) {
return 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");
export {
configure
};
//# sourceMappingURL=configure.js.map