ruta 0.1.16 copy "ruta: ^0.1.16" to clipboard
ruta: ^0.1.16 copied to clipboard

A lightweight and flexible backend framework for Dart, inspired by dart_frog.

Ruta Framework #

Ruta is a lightweight and flexible backend framework for Dart, inspired by dart_frog. It provides a simple and intuitive way to build RESTful APIs and web servers with a focus on developer productivity and performance.

Features #

  • Simple Routing: Define routes with ease using a clean and expressive syntax.
  • Middleware Support: Add middleware to handle cross-cutting concerns like logging, authentication, and more.
  • Lightweight: Minimal overhead for fast and efficient server-side applications.
  • Dart-Powered: Leverage the power of Dart for type safety and modern language features.

Getting Started #

  1. Add ruta to your pubspec.yaml:

    dependencies:
      ruta: ^0.1.9
      getIt: ^8.0.3
      injectable: ^2.3.2
    dev_dependencies:
      build_runner: ^2.4.13
      injectable_generator: ^2.6.2
      ruta_generator: ^0.1.8
    
  2. Create a route using Ruta's annotation-based system with dependency injection:

    import 'package:injectable/injectable.dart';
    import 'package:ruta/annotations.dart';
    import 'package:ruta/ruta.dart';
    
    @module
    abstract class DependencyContainer {
      @Named('apiVersion')
      String get apiVersion => '0.0.1';
    }
    
    @rutaRoute
    class InfoRoute extends Route {
      InfoRoute({
        @Named('apiVersion') required this.apiVersion,
      });
    
      final String apiVersion;
    
      Endpoint get index {
        return Endpoint.get(
          path: '',
          handler: (req) {
            return Response.json(
              body: {'apiVersion': apiVersion},
            );
          },
        );
       }
      }
    
  3. Activate Ruta CLI:

    dart pub global activate ruta_cli
    
  4. Generate code for server using ruta_cli:

    ruta build
    

    or use build_runner

    dart run build_runner build --delete-conflicting-outputs
    
  5. Run your server using the Ruta CLI:

    ruta run
    

Your server will start, and you can test the endpoint at http://localhost:8080/info

1
likes
130
points
925
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight and flexible backend framework for Dart, inspired by dart_frog.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

collection, get_it, http_parser, injectable, mime, shelf, shelf_cors_headers, shelf_hotreload, shelf_static, shelf_swagger_ui

More

Packages that depend on ruta