dartapi 0.1.4
dartapi: ^0.1.4 copied to clipboard
DartAPI is a CLI-driven project generator and toolset for building typed REST APIs in Dart. It provides modular packages for authentication, database access, request validation, and controller-based r [...]
DartAPI CLI #
DartAPI is a modular and developer-friendly CLI tool for building robust, typed REST APIs using the Dart language.
Rather than acting as a heavy, opinionated framework, DartAPI provides powerful code generation tools that let you build scalable backend applications with clean architecture, JWT authentication, request validation, and PostgreSQL/MySQL support.
๐ฆ What It Does #
- โ
Project scaffolding (
dartapi create) - โ
Controller generation (
dartapi generate controller) - โ
Hot-reload style dev server with keyboard controls (
dartapi run) - โ Integrated with:
๐ Installation #
Activate globally:
dart pub global activate dartapi
๐ CLI Commands #
dartapi create <project_name> #
Creates a full DartAPI project with:
bin/main.dart- Controllers (
UserController,AuthController,ProductController) - Middleware (
logging,auth) - JWT setup with
dartapi_auth - DB support with
dartapi_db - DTOs and validation helpers
- Auto schema definitions for future Swagger support
dartapi generate controller <Name> #
Adds a controller to an existing DartAPI project:
dartapi generate controller Product
Generates lib/src/controllers/product_controller.dart with GET and POST methods and proper typing.
dartapi run --port <port> #
Runs your DartAPI server using bin/main.dart.
You can control it interactively:
- Type
:qto quit - Type
rto reload
dartapi run --port=8080
๐งช Example Usage #
dartapi create my_app
cd my_app
dart pub get
dartapi run --port=8080
Now open Postman and test /users or /auth/login.
๐งฑ Generated Project Structure #
my_app/
โโโ bin/
โ โโโ main.dart
โโโ lib/
โ โโโ src/
โ โโโ core/ # Server/router setup
โ โโโ controllers/ # UserController, AuthController, etc.
โ โโโ dto/ # DTOs with schema
โ โโโ db/ # DB connection logic
โ โโโ middleware/ # Auth/logging middleware
โ โโโ utils/ # Validation, helpers
โโโ pubspec.yaml
โโโ analysis_options.yaml
โ Why Use DartAPI? #
- Minimal but powerful
- Follows clean architecture principles
- Type-safe routing using
ApiRoute<ApiInput, ApiOutput> - Built-in JWT auth and DB integration
- Ready to extend with OpenAPI/Swagger
๐ License #
BSD 3-Clause License ยฉ 2025 Akash G Krishnan
LICENSE
๐ Links #
- ๐ฆ Pub.dev: dartapi
- ๐ ๏ธ GitHub: github.com/akashgk/dartapi