@reliverse/rse-sdk
Version:
@reliverse/rse-sdk without cli. @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).
63 lines (62 loc) • 1.65 kB
JavaScript
import { re } from "@reliverse/relico";
import { cancel, isCancel, select } from "@reliverse/rempts";
import { DEFAULT_CONFIG } from "../constants.js";
export async function getBackendFrameworkChoice(backendFramework, frontends) {
if (backendFramework !== void 0) return backendFramework;
const hasIncompatibleFrontend = frontends?.some(
(f) => f === "nuxt" || f === "solid"
);
const backendOptions = [
{
value: "hono",
label: "Hono",
hint: "Lightweight, ultrafast web framework"
},
{
value: "next",
label: "Next.js",
hint: "separate api routes only backend"
},
{
value: "express",
label: "Express",
hint: "Fast, unopinionated, minimalist web framework for Node.js"
},
{
value: "fastify",
label: "Fastify",
hint: "Fast, low-overhead web framework for Node.js"
},
{
value: "elysia",
label: "Elysia",
hint: "Ergonomic web framework for building backend servers"
}
];
if (!hasIncompatibleFrontend) {
backendOptions.push({
value: "convex",
label: "Convex",
hint: "Reactive backend-as-a-service platform"
});
}
backendOptions.push({
value: "none",
label: "None",
hint: "No backend server"
});
let initialValue = DEFAULT_CONFIG.backend;
if (hasIncompatibleFrontend && initialValue === "convex") {
initialValue = "hono";
}
const response = await select({
message: "Select backend",
options: backendOptions,
initialValue
});
if (isCancel(response)) {
cancel(re.red("Operation cancelled"));
process.exit(0);
}
return response;
}