Skip to content

Dart server-side framework: routing, ORM and OAuth 2.0 in a consistent, rigorously tested framework.

License

Notifications You must be signed in to change notification settings

rahatray/aqueduct

 
 

Repository files navigation

Aqueduct

Build Status codecov

Gitter

Aqueduct is a server-side framework for building and deploying REST applications. It is written in Dart. Its goal is to provide an integrated, consistently styled API.

The framework contains behavior for routing and authorizing HTTP requests, persisting data in PostgreSQL, testing, and more.

The aqueduct command-line tool serves applications, manages database schemas and OAuth 2.0 clients, and generates OpenAPI specifications.

Aqueduct is well-tested, documented and adheres to semantic versioning.

Getting Started

  1. Install Dart.

  2. Activate Aqueduct

     pub global activate aqueduct
    
  3. Create a new project.

     aqueduct create my_project
    

Open the project directory in an IntelliJ IDE, Atom or Visual Studio Code. All three IDEs have a Dart plugin.

Tutorials and Documentation

Step-by-step tutorials for beginners are available here.

You can find the API reference here or you can install it in Dash.

You can find in-depth and conceptual guides here.

An Example

The only requirement of an Aqueduct application is that it contains a single RequestSink subclass. The example application below exposes POST /notes, GET /notes, GET /notes/:id, PUT /notes/:id and DELETE /notes/:id and stores data in a PostgreSQL database.

import 'package:aqueduct/aqueduct.dart';

class AppRequestSink extends RequestSink {
  AppRequestSink(ApplicationConfiguration config) : super(config) {
    logger.onRecord.listen((p) => print("$p"));

    var dataModel = new ManagedDataModel.fromCurrentMirrorSystem();
    var psc = new PostgreSQLPersistentStore.fromConnectionInfo(
        "dart", "dart", "localhost", 5432, "dart_test");

    ManagedContext.defaultContext = new ManagedContext(dataModel, psc);
  }

  @override
  void setupRouter(Router router) {
    router
      .route("/notes[/:id]")
      .generate(() => new ManagedObjectController<Note>());
  }
}

class Note extends ManagedObject<_Note> implements _Note {}
class _Note {
  @managedPrimaryKey
  int id;

  String contents;
}

About

Dart server-side framework: routing, ORM and OAuth 2.0 in a consistent, rigorously tested framework.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 99.9%
  • Other 0.1%