@api-buddy/cli v0.4.111
@api-buddy/cli
Command Line Interface for API Buddy, providing utilities for scaffolding and managing API Buddy projects with ease.
š Current Status
ā Implemented
- Basic project scaffolding with
init
command - Interactive project setup with prompts
- TypeScript configuration
- Basic project structure generation
- Package manager detection (npm, yarn, pnpm)
š§ In Progress
generate
command implementation- File watching and hot reload
- Plugin system integration
- Database integration (Prisma)
Features
- š Project Initialization: Scaffold new API Buddy projects with modern setup
- āļø Interactive Setup: Guided project configuration
- š¦ Package Management: Works with npm, Yarn, and pnpm
- š TypeScript Ready: Pre-configured TypeScript support
- šļø Modular Architecture: Built for extensibility
Installation
# Using npm
npm install -g @api-buddy/cli
# Using Yarn
yarn global add @api-buddy/cli
# Using pnpm
pnpm add -g @api-buddy/cli
Quick Start
Initialize a New Project
api-buddy init my-api
cd my-api
This will guide you through an interactive setup process where you can:
- Choose your preferred package manager
- Select a database (PostgreSQL, MySQL, MongoDB, or SQLite)
- Set up authentication (JWT, OAuth, or none)
- Configure TypeScript settings
- Install dependencies automatically
Start Development Server
api-buddy dev
This will start the development server with hot-reloading enabled.
Available Commands
init [directory]
Initialize a new API Buddy project in the specified directory (or current directory if not specified).
Options:
--use-npm
: Use npm as the package manager--use-yarn
: Use Yarn as the package manager--use-pnpm
: Use pnpm as the package manager
generate
Generate code from schema definitions.
Options:
-w, --watch
: Watch for changes and regenerate automatically-o, --out-dir <dir>
: Output directory (default: .api-buddy)-s, --schema <file>
: Path to schema file (default: api-buddy.config.ts)
dev
Start the development server.
build
Build the project for production.
test
Run tests.
Project Structure
A typical API Buddy project structure looks like this:
my-api/
āāā src/
ā āāā config/ # Configuration files
ā āāā models/ # Data models
ā āāā routes/ # API routes
ā āāā services/ # Business logic
āāā .env # Environment variables
āāā .env.example # Example environment variables
āāā package.json # Project dependencies and scripts
āāā tsconfig.json # TypeScript configuration
Configuration
Create an api-buddy.config.ts
file in your project root to customize the CLI behavior. Here's an example configuration:
import { defineConfig } from '@api-buddy/core';
export default defineConfig({
server: {
port: 3000,
host: '0.0.0.0',
},
database: {
client: 'postgresql',
connection: {
host: process.env.DB_HOST,
port: process.env.DB_PORT,
database: process.env.DB_NAME,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
},
},
// ... other configurations
});
Plugins
API Buddy supports a rich plugin ecosystem. You can add plugins to extend functionality:
// api-buddy.config.ts
export default defineConfig({
plugins: [
// Add plugins here
],
});
Contributing
Contributions are welcome! Please read our contributing guidelines to get started.
License
MIT