@reliverse/rse-sdk
Version:
@reliverse/rse-sdk allows you to create new plugins for @reliverse/rse CLI, interact with reliverse.org, and even extend your own CLI functionality (you may also try @reliverse/dler-sdk for this case).
53 lines (52 loc) • 1.46 kB
JavaScript
import { re } from "@reliverse/relico";
import { cancel, isCancel, select } from "@reliverse/rempts";
export async function getApiChoice(Api, frontend, backend) {
if (backend === "convex" || backend === "none") {
return "none";
}
if (Api) return Api;
const includesNuxt = frontend?.includes("nuxt");
const includesSvelte = frontend?.includes("svelte");
const includesSolid = frontend?.includes("solid");
let apiOptions = [
{
value: "trpc",
label: "tRPC",
hint: "End-to-end typesafe APIs made easy"
},
{
value: "orpc",
label: "oRPC",
hint: "End-to-end type-safe APIs that adhere to OpenAPI standards"
},
{
value: "none",
label: "None",
hint: "No API layer (e.g. for full-stack frameworks like Next.js with Route Handlers)"
}
];
if (includesNuxt || includesSvelte || includesSolid) {
apiOptions = [
{
value: "orpc",
label: "oRPC",
hint: `End-to-end type-safe APIs (Recommended for ${includesNuxt ? "Nuxt" : includesSvelte ? "Svelte" : "Solid"} frontend)`
},
{
value: "none",
label: "None",
hint: "No API layer"
}
];
}
const apiType = await select({
message: "Select API type",
options: apiOptions,
initialValue: apiOptions[0]?.value ?? "none"
});
if (isCancel(apiType)) {
cancel(re.red("Operation cancelled"));
process.exit(0);
}
return apiType;
}