Angel3 Framework

Angel3 Framework

Pub Version (including pre-releases) Null Safety Discord License melos

Angel3 framework is a high-powered HTTP server with support for dependency injection, sophisticated routing, authentication, ORM, graphql etc. It is designed to keep the core minimal but extensible through a series of plugin packages. It won't dictate which features, databases or web templating engine to use. This flexibility enable Angel3 framework to grow with your application as new features can be added to handle the new use cases.

This package is the core package of Angel3. For more information, visit us at Angel3 Website.

Installation and Setup

(Option 1) Create a new project by cloning from boilerplate templates

  1. Download and install Dart

  2. Clone one of the following starter projects:

  3. Run the project in development mode (hot-reloaded is enabled on file changes).

    dart --observe bin/dev.dart
    
  4. Run the project in production mode (hot-reloaded is disabled).

    dart bin/prod.dart
    
  5. Run as docker. Edit and build the image with the provided Dockerfile file.

(Option 2) Create a new project with Angel3 CLI

  1. Download and install Dart

  2. Install the Angel3 CLI:

    dart pub global activate angel3_cli
    
  3. On terminal, create a new project:

    angel3 init hello
    
  4. Run the project in development mode (hot-reloaded is enabled on file changes).

    dart --observe bin/dev.dart
    
  5. Run the project in production mode (hot-reloaded is disabled).

    dart bin/prod.dart
    
  6. Run as docker. Edit and build the image with the provided Dockerfile file.

Running without dart:mirrors (AOT)

dart compile exe and Flutter do not support dart:mirrors. Create the app without a reflector and it runs with reflection disabled:

var app = Angel(); // no MirrorsReflector

app.container.registerSingleton(Greeter());   // register what you inject
app.use('/api/todos', MapService());           // services and hooks work as usual

// Inject with an explicit InjectionRequest instead of reflecting on the closure.
app.get('/greet/:name', ioc(
  (Greeter greeter, String name) => greeter.greet(name),
  injection: InjectionRequest.constant(required: [Greeter, ['name', String]]),
));

// Controllers take their mount path from `expose` and add routes in `configureRoutes`.
class HealthController extends Controller {
  HealthController() : super(expose: const Expose('/health'));

  @override
  void configureRoutes(Routable routable) =>
      routable.get('/', (req, res) => {'status': 'ok'});
}

Without reflection, these features are unavailable: @Expose on controller methods, the @Middleware and @Hooks annotations (they are ignored), automatic constructor injection in container.make, and ioc without injection:. See example/no_mirrors.dart for a complete app.

Request limits

req.parseBody() (also used by services) reads at most app.maxBodySize bytes, 10 MB by default, and answers larger requests with 413 Payload Too Large:

var app = Angel()..maxBodySize = 1024 * 1024; // 1 MB for the whole app

// Allow larger bodies on one route by raising the limit before parsing.
app.post('/upload', uploadHandler, middleware: [
  (req, res) {
    req.maxBodySize = 100 * 1024 * 1024; // 100 MB
    return true;
  },
]);

Set app.maxBodySize = null to remove the limit. In production, resolved routes are cached per request path; the cache holds at most app.maxHandlerCacheSize entries (1024 by default, 0 disables it).

Performance Benchmark

The performance benchmark can be found at

TechEmpower Framework Benchmarks Round 21

Migrating from Angel to Angel3

Check out Migrating to Angel3

Donation & Support

If you like this project and interested in supporting its development, you can make a donation using the following services:

Libraries

angel3_framework
An easily-extensible web server framework in Dart.
http
http2