aqueduct 2.2.0 aqueduct: ^2.2.0 copied to clipboard
Server-side framework, including routing, ORM and OAuth 2.0 in a consistent, rigorously tested framework.
Aqueduct is a server-side framework for building and deploying REST applications. It is written in Dart. Its goal to provide am integrated and consistently styled framework.
It contains behavior for routing and authorizing HTTP requests, persisting data in PostgreSQL, testing, and much 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 #
-
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.
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 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;
}