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.
-
Activate Aqueduct
pub global activate aqueduct
-
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.
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.
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;
}