### Create ElysiaJS Project with Bun Source: https://github.com/kravetsone/create-elysiajs/blob/main/README.md Use this command to scaffold a new ElysiaJS project. Ensure you have bun installed. ```bash bun create elysiajs ``` -------------------------------- ### Determine Post-Generation Shell Commands Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Returns an ordered list of shell commands to execute after project files are written, including git initialization, dependency installation, and linter/ORM setup. ```typescript import { getInstallCommands } from "./templates"; import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.git = true; prefs.linter = "Biome"; prefs.orm = "Prisma"; prefs.database = "PostgreSQL"; prefs.others = ["Husky"]; console.log(getInstallCommands(prefs)); // [ // "git init", // "bun install", // 'echo "bun lint:fix" > .husky/pre-commit', // "bunx prisma init --datasource-provider postgresql", // "bunx @biomejs/biome init", // "bun lint:fix" // ] ``` -------------------------------- ### Generate Drizzle Configuration (`drizzle.config.ts`) Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Produces the Drizzle Kit configuration file. Ensure 'env-var' is installed and DATABASE_URL is set in your environment. ```typescript import { getDrizzleConfig } from "./templates"; import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.database = "PostgreSQL"; console.log(getDrizzleConfig(prefs)); ``` ```typescript import type { Config } from "drizzle-kit" import env from "env-var" const DATABASE_URL = env.get("DATABASE_URL").required().asString() export default { schema: "./src/db/schema.ts", out: "./drizzle", dialect: "postgresql", casing: "snake_case", dbCredentials: { url: DATABASE_URL } } satisfies Config ``` -------------------------------- ### Scaffold New Elysia Project with create-elysiajs Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Use this command to initiate the scaffolding process for a new ElysiaJS project. You can specify the target directory and use flags to customize the process, such as skipping dependency installation or running within a monorepo. ```bash # Scaffold into a new directory named "my-api" bun create elysiajs my-api # Scaffold as part of a monorepo (skips linter/ORM/docker/vscode prompts) bun create elysiajs apps/server --monorepo # Skip dependency installation bun create elysiajs my-api --install false ``` -------------------------------- ### Generate multi-stage `Dockerfile` Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Produces a production-ready multi-stage Dockerfile for Bun or Node.js. It includes separate stages for installation, prerelease (type-checking), and release, automatically copying ORM migration files. ```typescript import { getDockerfile } from "./templates/docker"; import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.packageManager = "bun"; prefs.orm = "Drizzle"; console.log(getDockerfile(prefs)); /* FROM oven/bun:1.x AS base WORKDIR /usr/src/app FROM base AS install RUN mkdir -p /temp/dev COPY package.json bun.lock /temp/dev/ RUN cd /temp/dev && bun install --frozen-lockfile ... FROM base AS release COPY --from=install /temp/prod/node_modules node_modules ... COPY --from=prerelease /usr/src/app/drizzle ./drizzle COPY --from=prerelease /usr/src/app/drizzle.config.ts . ENTRYPOINT [ "bun", "start" ] */ ``` -------------------------------- ### bun create elysiajs Source: https://context7.com/kravetsone/create-elysiajs/llms.txt The primary command to scaffold a new Elysia project. It guides the user through interactive prompts to configure the project and automatically generates all necessary files and configurations. ```APIDOC ## bun create elysiajs — scaffold a new Elysia project ### Description This command is the main entry point for creating a new Elysia project. It parses CLI arguments, creates the target directory, and initiates an interactive questionnaire to gather user preferences for linters, ORMs, plugins, and infrastructure integrations. Finally, it generates all project files with the chosen configurations. ### Usage ```bash # Scaffold into a new directory named "my-api" bun create elysiajs my-api # Scaffold as part of a monorepo (skips linter/ORM/docker/vscode prompts) bun create elysiajs apps/server --monorepo # Skip dependency installation bun create elysiajs my-api --install false ``` ``` -------------------------------- ### Generate Elysia Server Index (`src/server.ts`) Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Generates the Elysia app definition, including selected plugins and the default GET / route. Ensure necessary plugins are configured in Preferences. ```typescript import { getElysiaIndex } from "./templates"; import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.plugins = ["CORS", "Swagger", "JWT", "Bearer", "Server Timing"]; prefs.telegramRelated = false; console.log(getElysiaIndex(prefs)); ``` ```typescript import { Elysia } from "elysia" import { config } from "./config.ts" import { cors } from "@elysiajs/cors" import { swagger } from "@elysiajs/swagger" import { jwt } from "@elysiajs/jwt" import { bearer } from "@elysiajs/bearer" import { serverTiming } from "@elysiajs/server-timing" export const app = new Elysia() .use(cors()) .use(swagger()) .use(jwt({ secret: config.JWT_SECRET })) .use(bearer()) .use(serverTiming()) .get("/", "Hello World") ``` -------------------------------- ### Generate Telegram Bot Instance Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Generates the `src/bot.ts` file for a GramIO Telegram bot instance. The bot logs its username upon starting. ```typescript import { getBotFile } from "./templates/bot"; console.log(getBotFile()); /* import { Bot } from "gramio"; import { config } from "./config.ts"; export const bot = new Bot(config.BOT_TOKEN) .onStart(({ info }) => console.log(`✨ Bot ${info.username} was started!`)) */ ``` -------------------------------- ### Generate `src/services/jobify.ts` Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Creates the Jobify initializer, a type-safe wrapper for BullMQ, connected to the shared Redis instance. This setup facilitates easy definition and management of background jobs. ```typescript import { getJobifyFile } from "./templates/services/jobify"; console.log(getJobifyFile()); /* import { initJobify } from "jobify" import { redis } from "./redis.ts" export const defineJob = initJobify(redis); */ // Usage in the generated project: // const sendEmailJob = defineJob("send-email", async (data: { to: string }) => { // await sendEmail(data.to); // }); // await sendEmailJob.add({ to: "user@example.com" }); ``` -------------------------------- ### Generate Test API Client and E2E Test Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Creates an Eden Treaty client for type-safe HTTP testing and a sample E2E test for the default GET / route. ```typescript import { getTestsAPIFile, getTestsIndex } from "./templates/tests"; import { Preferences } from "./utils"; const prefs = new Preferences(); // tests/api.ts console.log(getTestsAPIFile(prefs)); /* import { treaty } from "@elysiajs/eden"; import { app } from "../src/server.ts"; export const api = treaty(app); */ // tests/e2e/index.test.ts console.log(getTestsIndex(prefs)); /* import { describe, it, expect } from "bun:test"; import { api } from "../api.ts"; describe("API - /", () => { it("/ - should return hello world", async () => { const response = await api.index.get(); expect(response.status).toBe(200); expect(response.data).toBe("Hello World"); }); }); */ // Run tests: // bun test ``` -------------------------------- ### Generate Database Initialization (`src/db/index.ts`) Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Produces the database initialization file for various ORMs and drivers like Prisma and Drizzle. Ensure 'config' and 'SQL' are imported if using Drizzle with Bun.sql. ```typescript import { getDBIndex } from "./templates"; import { Preferences } from "./utils"; // Prisma const prismaPrefs = new Preferences(); prismaPrefs.orm = "Prisma"; console.log(getDBIndex(prismaPrefs)); ``` ```typescript import { PrismaClient } from "@prisma/client" export const prisma = new PrismaClient() export * from "@prisma/client" ``` ```typescript // Drizzle + Bun.sql (PostgreSQL) const drizzlePrefs = new Preferences(); drizzlePrefs.orm = "Drizzle"; drizzlePrefs.driver = "Bun.sql"; console.log(getDBIndex(drizzlePrefs)); ``` ```typescript import { drizzle } from "drizzle-orm/bun-sql" import { config } from "../config.ts" import { SQL } from "bun" export const sql = new SQL(config.DATABASE_URL) export const db = drizzle({ client: sql, casing: "snake_case" }) ``` -------------------------------- ### Generate Index Entry Point (`src/index.ts`) Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Generates the server entry file with graceful shutdown handlers, optional database connection, and Telegram bot logic. Requires 'app' and 'config' imports. ```typescript import { getIndex } from "./templates"; import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.orm = "Drizzle"; prefs.driver = "node-postgres"; // requires explicit connect() prefs.others = ["Posthog"]; prefs.telegramRelated = false; console.log(getIndex(prefs)); ``` ```typescript import { config } from "./config.ts" import { app } from "./server.ts" import { posthog } from "./services/posthog.ts" import { client } from "./db/index.ts" const signals = ["SIGINT", "SIGTERM"]; for (const signal of signals) { process.on(signal, async () => { console.log(`Received ${signal}. Initiating graceful shutdown...`); await app.stop() await posthog.shutdown() process.exit(0); }) } process.on("uncaughtException", (error) => { console.error(error); }) process.on("unhandledRejection", (error) => { console.error(error); }) await client.connect() console.log("🗄️ Database was connected!") app.listen(config.PORT, () => console.log(`🦊 Server started at ${app.server?.url.origin}`)) ``` -------------------------------- ### Generate `tests/preload.ts` for `bun:test` Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Generates a `bun:test` preload file to mock the database driver with PGLite and optionally ioredis. It also runs Drizzle migrations before tests execute. ```typescript import { getPreloadFile } from "./templates/tests"; import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.driver = "node-postgres"; prefs.redis = true; console.log(getPreloadFile(prefs)); /* import { mock } from "bun:test"; import { join } from "node:path"; import { PGlite } from "@electric-sql/pglite"; import { drizzle } from "drizzle-orm/pglite"; import { migrate } from "drizzle-orm/pglite/migrator"; import redis from "ioredis-mock"; console.time("PGLite init"); const pglite = new PGlite(); export const db = drizzle(pglite); mock.module("pg", () => ({ default: () => pglite })); mock.module("drizzle-orm/node-postgres", () => ({ drizzle })); mock.module('ioredis', () => ({ Redis: redis, default: redis })); await migrate(db, { migrationsFolder: join(import.meta.dir, "..", "drizzle") }); console.timeEnd("PGLite init"); */ ``` -------------------------------- ### Manage Project Configuration with Preferences Class Source: https://context7.com/kravetsone/create-elysiajs/llms.txt The `Preferences` class is used to store and manage all user selections made during the interactive scaffolding process. It holds project name, package manager, linter, ORM, plugins, and other integration choices. Generators typically accept an instance of this class. ```typescript import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.projectName = "my-api"; prefs.packageManager = "bun"; prefs.runtime = "Bun"; prefs.linter = "Biome"; prefs.orm = "Drizzle"; prefs.database = "PostgreSQL"; prefs.driver = "Bun.sql"; prefs.plugins = ["CORS", "Swagger", "JWT"]; prefs.others = ["S3", "Posthog"]; prefs.redis = true; prefs.locks = true; prefs.docker = true; prefs.vscode = true; prefs.mockWithPGLite = true; prefs.telegramRelated = false; ``` -------------------------------- ### Generate package.json with getPackageJson(prefs) Source: https://context7.com/kravetsone/create-elysiajs/llms.txt This function constructs the `package.json` content as a JSON string, populating scripts, dependencies, and devDependencies based on the provided `Preferences` object. It ensures all chosen configurations are reflected in the project's package manifest. ```typescript import { getPackageJson } from "./templates"; import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.projectName = "my-api"; prefs.packageManager = "bun"; prefs.linter = "Biome"; prefs.orm = "Drizzle"; prefs.database = "PostgreSQL"; prefs.driver = "node-postgres"; prefs.plugins = ["Swagger", "JWT", "CORS"]; prefs.others = ["Husky"]; prefs.redis = true; prefs.mockWithPGLite = true; const json = getPackageJson(prefs); console.log(json); /* { "name": "my-api", "type": "module", "scripts": { "dev": "bun --watch src/index.ts", "start": "NODE_ENV=production bun run ./src/index.ts", "lint": "bun x @biomejs/biome check src", "lint:fix": "bun lint --write", "generate": "bun x drizzle-kit generate", "push": "bun x drizzle-kit push", "migrate": "bun x drizzle-kit migrate", "studio": "bun x drizzle-kit studio", "prepare": "husky" }, "dependencies": { "elysia": "^1.4.16", "env-var": "^7.5.0", ... }, "devDependencies": { "typescript": "^5.9.3", "@types/bun": "^1.3.2", ... } } */ ``` -------------------------------- ### Generate VSCode Settings and Extensions Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Produces `.vscode/settings.json` for format-on-save and default formatter, and `.vscode/extensions.json` with curated extension recommendations. ```typescript import { getVSCodeSettings, getVSCodeExtensions } from "./templates/vscode"; import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.linter = "Biome"; prefs.packageManager = "bun"; prefs.docker = true; prefs.orm = "Drizzle"; console.log(getVSCodeSettings(prefs)); /* { "editor.formatOnSave": true, "[javascript]": { "editor.defaultFormatter": "biomejs.biome" }, "[typescript]": { "editor.defaultFormatter": "biomejs.biome" } } */ console.log(getVSCodeExtensions(prefs)); /* { "recommendations": [ "usernamehw.errorlens", "YoavBls.pretty-ts-errors", "meganrogge.template-string-converter", "oven.bun-vscode", "biomejs.biome", "ms-azuretools.vscode-docker", "rphlmr.vscode-drizzle-orm" ] } */ ``` -------------------------------- ### getPackageJson(prefs) Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Generates the content for the `package.json` file based on the provided Preferences object. It includes scripts, dependencies, and devDependencies tailored to the project's configuration. ```APIDOC ## getPackageJson(prefs) ### Description This function constructs a complete `package.json` object, serialized as a JSON string, based on the project's configuration stored in a `Preferences` object. It populates `scripts`, `dependencies`, and `devDependencies` according to the selected options, ensuring a fully configured project ready for use. ### Parameters - **prefs** (Preferences) - Required - An instance of the `Preferences` class containing the project's configuration. ### Returns - **string** - A JSON string representing the `package.json` content. ### Request Example ```typescript import { getPackageJson } from "./templates"; import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.projectName = "my-api"; prefs.packageManager = "bun"; prefs.linter = "Biome"; prefs.orm = "Drizzle"; prefs.database = "PostgreSQL"; prefs.driver = "node-postgres"; prefs.plugins = ["Swagger", "JWT", "CORS"]; prefs.others = ["Husky"]; prefs.redis = true; prefs.mockWithPGLite = true; const json = getPackageJson(prefs); console.log(json); /* { "name": "my-api", "type": "module", "scripts": { "dev": "bun --watch src/index.ts", "start": "NODE_ENV=production bun run ./src/index.ts", "lint": "bun x @biomejs/biome check src", "lint:fix": "bun lint --write", "generate": "bun x drizzle-kit generate", "push": "bun x drizzle-kit push", "migrate": "bun x drizzle-kit migrate", "studio": "bun x drizzle-kit studio", "prepare": "husky" }, "dependencies": { "elysia": "^1.4.16", "env-var": "^7.5.0", ... }, "devDependencies": { "typescript": "^5.9.3", "@types/bun": "^1.3.2", ... } } */ ``` ``` -------------------------------- ### Generate Environment Files (`.env`, `.env.production`) Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Generates environment variable files. Set `isComposed` to true to use Docker Compose service names for hosts. ```typescript import { getEnvFile } from "./templates"; import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.projectName = "my-api"; prefs.orm = "Drizzle"; prefs.database = "PostgreSQL"; prefs.redis = true; prefs.plugins = ["JWT"]; console.log(getEnvFile(prefs)); ``` ```plaintext DATABASE_URL="postgresql://my-api:a3f8bc12d0e1@localhost:5432/my-api" REDIS_HOST=redis ← only in composed version JWT_SECRET="9f1e2a..." PORT=3000 ``` ```typescript console.log(getEnvFile(prefs, true)); // for docker-compose ``` ```plaintext DATABASE_URL="postgresql://my-api:a3f8bc12d0e1@postgres:5432/my-api" ``` -------------------------------- ### Generate S3 Client Service Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Generates the `src/services/s3.ts` file for an S3 client. Supports both Bun's native `S3Client` and the `@aws-sdk/client-s3` library, configured via `config`. ```typescript import { getS3ServiceFile } from "./templates/services/s3"; import { Preferences } from "./utils"; // Bun native S3 client const bunPrefs = new Preferences(); bunPrefs.s3Client = "Bun.S3Client"; console.log(getS3ServiceFile(bunPrefs)); /* import { S3Client } from "bun"; import { config } from "../config.ts"; export const s3 = new S3Client({ endpoint: config.S3_ENDPOINT, accessKeyId: config.S3_ACCESS_KEY_ID, secretAccessKey: config.S3_SECRET_ACCESS_KEY, }); */ // AWS SDK client const awsPrefs = new Preferences(); awsPrefs.s3Client = "@aws-sdk/client-s3"; console.log(getS3ServiceFile(awsPrefs)); /* import { S3Client } from "@aws-sdk/client-s3"; import { config } from "../config.ts"; export const s3 = new S3Client({ endpoint: config.S3_ENDPOINT, region: "minio", credentials: { accessKeyId: config.S3_ACCESS_KEY_ID, secretAccessKey: config.S3_SECRET_ACCESS_KEY, }, }); */ ``` -------------------------------- ### Generate `src/services/redis.ts` Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Creates a pre-configured ioredis client. Sets `maxRetriesPerRequest` to `null`, which is necessary for compatibility with libraries like BullMQ and Jobify. ```typescript import { getRedisFile } from "./templates/services/redis"; console.log(getRedisFile()); /* import { Redis } from "ioredis"; import { config } from "../config.ts" export const redis = new Redis({ host: config.REDIS_HOST, // for bullmq maxRetriesPerRequest: null, }) */ ``` -------------------------------- ### Generate Docker Compose files Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Generates production (`docker-compose.yml`) and development (`docker-compose.dev.yml`) Docker Compose files. The production version omits exposed ports for database and Redis, while the development version exposes them for local debugging. ```typescript import { getDockerCompose, getDevelopmentDockerCompose } from "./templates/docker"; import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.projectName = "my-api"; prefs.database = "PostgreSQL"; prefs.redis = true; prefs.others = ["S3"]; prefs.meta = { databasePassword: "abc123def456" }; // Production compose (no exposed DB ports) console.log(getDockerCompose(prefs)); /* services: bot: container_name: my-api-bot restart: unless-stopped build: { context: ., dockerfile: Dockerfile } environment: [ NODE_ENV=production ] postgres: container_name: my-api-postgres image: postgres:latest ... redis: container_name: my-api-redis image: redis:latest ... minio: container_name: my-api-minio image: minio/minio:latest ports: [ "9000:9000", "9001:9001" ] ... volumes: postgres_data: redis_data: minio_data: */ // Dev compose (DB and Redis ports exposed) console.log(getDevelopmentDockerCompose(prefs)); // postgres exposes 5432:5432, redis exposes 6379:6379 ``` -------------------------------- ### Generate `src/config.ts` with `env-var` Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Generates a typed and validated configuration module using `env-var`. Ensure all required environment variables are set before application startup. ```typescript import { getConfigFile } from "./templates"; import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.orm = "Drizzle"; prefs.redis = true; prefs.locks = true; prefs.plugins = ["JWT"]; prefs.others = ["Posthog", "S3"]; console.log(getConfigFile(prefs)); /* import env from "env-var"; export const config = { NODE_ENV: env.get("NODE_ENV").default("development").asEnum(["production", "test", "development"]), PORT: env.get("PORT").default(3000).asPortNumber(), API_URL: env.get("API_URL").default(`https://${env.get("PUBLIC_DOMAIN").asString()}`).asString(), DATABASE_URL: env.get("DATABASE_URL").required().asString(), REDIS_HOST: env.get("REDIS_HOST").default("localhost").asString(), POSTHOG_API_KEY: env.get("POSTHOG_API_KEY").default("it's a secret").asString(), POSTHOG_HOST: env.get("POSTHOG_HOST").default("localhost").asString(), S3_ENDPOINT: env.get("S3_ENDPOINT").default("localhost").asString(), S3_ACCESS_KEY_ID: env.get("S3_ACCESS_KEY_ID").default("minio").asString(), S3_SECRET_ACCESS_KEY: env.get("S3_SECRET_ACCESS_KEY").default("minio").asString(), LOCK_STORE: env.get("LOCK_STORE").default("memory").asEnum(["memory","redis"]), JWT_SECRET: env.get("JWT_SECRET").required().asString(), } */ ``` -------------------------------- ### Generate Telegram Mini App Auth Plugin Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Generates the `src/services/auth.plugin.ts` file for an Elysia plugin that handles Telegram Mini App authentication. It validates `initData` from the `x-init-data` header, resolving `tgId` and `user` into route context. ```typescript import { getAuthPlugin } from "./templates/services/auth"; console.log(getAuthPlugin()); /* import { validateAndParseInitData, signInitData, getBotTokenSecretKey } from "@gramio/init-data"; import { Elysia, t } from "elysia"; import { config } from "../config.ts"; const secretKey = getBotTokenSecretKey(config.BOT_TOKEN); export const authElysia = new Elysia({ name: "auth" }) .guard({ headers: t.Object({ "x-init-data": t.String({ examples: [...] }) }), response: { 401: t.Literal("UNAUTHORIZED") }, }) .resolve(({ headers, error }) => { const result = validateAndParseInitData(headers["x-init-data"], secretKey); if (!result || !result.user) return error("Unauthorized", "UNAUTHORIZED"); return { tgId: result.user.id, user: result.user }; }) .as("plugin"); */ // Usage in the generated project: // app.use(authElysia).get("/me", ({ user }) => user); ``` -------------------------------- ### Generate PostHog Analytics Client Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Generates the `src/services/posthog.ts` file for a PostHog analytics client. The client is automatically disabled outside of production environments to reduce noise. ```typescript import { getPosthogIndex } from "./templates/services/posthog"; console.log(getPosthogIndex()); /* import { PostHog } from "posthog-node"; import { config } from "../config.ts"; export const posthog = new PostHog(config.POSTHOG_API_KEY, { host: config.POSTHOG_HOST, disabled: config.NODE_ENV !== "production", }); posthog.on("error", (err) => { console.error("PostHog had an error!", err) }) */ // Usage in the generated project: // posthog.capture({ distinctId: "user-42", event: "signed_up" }); // await posthog.shutdown(); // called in graceful shutdown ``` -------------------------------- ### Detect Package Manager with detectPackageManager() Source: https://context7.com/kravetsone/create-elysiajs/llms.txt This utility function detects the active package manager by reading the `npm_config_user_agent` environment variable. It returns the detected package manager name or throws an error if the user agent is not found. Ensure this is run in an environment where the user agent is set. ```typescript import { detectPackageManager } from "./utils"; // Returns "bun" | "npm" | "yarn" | "pnpm" const pm = detectPackageManager(); // Expected output when run via bun: "bun" ``` -------------------------------- ### detectPackageManager() Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Detects the active package manager by reading the npm_config_user_agent environment variable. This function is crucial for ensuring consistent dependency management. ```APIDOC ## detectPackageManager() ### Description This utility function detects which package manager (Bun, npm, Yarn, or pnpm) is currently being used by inspecting the `npm_config_user_agent` environment variable. It is essential for maintaining consistency in project setup and dependency installation. ### Usage ```typescript import { detectPackageManager } from "./utils"; // Returns "bun" | "npm" | "yarn" | "pnpm" const pm = detectPackageManager(); // Expected output when run via bun: "bun" ``` ### Throws Throws an error if no `npm_config_user_agent` is found. ``` -------------------------------- ### Preferences class Source: https://context7.com/kravetsone/create-elysiajs/llms.txt A central data class that stores all user choices made during the interactive scaffolding process. It is used by template generators to configure the project. ```APIDOC ## Preferences class ### Description The `Preferences` class serves as a central repository for all configuration options selected by the user during the `create-elysiajs` interactive prompts. Instances of this class, or its type `PreferencesType`, are passed to various template generators to ensure the project is built according to the user's specifications. ### Usage ```typescript import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.projectName = "my-api"; prefs.packageManager = "bun"; prefs.runtime = "Bun"; prefs.linter = "Biome"; prefs.orm = "Drizzle"; prefs.database = "PostgreSQL"; prefs.driver = "Bun.sql"; prefs.plugins = ["CORS", "Swagger", "JWT"]; prefs.others = ["S3", "Posthog"]; prefs.redis = true; prefs.locks = true; prefs.docker = true; prefs.vscode = true; prefs.mockWithPGLite = true; prefs.telegramRelated = false; ``` ``` -------------------------------- ### Generate Verrou Distributed Lock Manager Source: https://context7.com/kravetsone/create-elysiajs/llms.txt Generates the `src/services/locks.ts` file for a Verrou distributed lock manager. Supports both memory and Redis stores, configurable via `config.LOCK_STORE`. ```typescript import { getLocksFile } from "./templates/services/locks"; import { Preferences } from "./utils"; const prefs = new Preferences(); prefs.redis = true; console.log(getLocksFile(prefs)); /* import { Verrou } from "@verrou/core" import { config } from "../config.ts" import { memoryStore } from '@verrou/core/drivers/memory' import { redisStore } from '@verrou/core/drivers/redis' import { redis } from './redis.ts' export const verrou = new Verrou({ default: config.LOCK_STORE, stores: { memory: { driver: memoryStore() }, redis: { driver: redisStore({ connection: redis }) }, } }) */ // Usage in the generated project: // await verrou.createLock("user:42:update").run(async () => { // await updateUser(42); // }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.