Aqueduct is an extensible HTTP framework for building REST APIs on top of the Dart VM. It includes a statically-typed ORM, OAuth 2.0 provider, automated testing libraries and OpenAPI 3.0 integration.
λ brew install dart λ pub global activate aqueduct λ aqueduct create my_app λ cd my_app λ aqueduct serve
Incredible documentation and a Slack channel for when you get stuck. For more detailed setup instructions, see this guide.
Aqueduct's memory-isolated threads leverage every CPU without writing any code. No race conditions or complicated synchronization logic to worry about.
A familiar, higher-order functional syntax makes application flow easy to construct and read.
router
.route('/teams/[:id]')
.link(() => Authorizer(validator))
.link(() => TeamController(databaseContext));
Powerful, statically typed queries enable code-completion and refactoring tools while minimizing error. Tested command-line tooling for database migrations makes data management a breeze.
final query = Query<Team>(context)
..where((t) => t.skills).contains('aqueduct')
..join(object: (t) => t.manager)
..join(set: (t) => t.developers);
final teams = await query.fetch();
A rigorously tested OAuth 2.0 server in just a few lines of code. A layered implementation allows you to store tokens and client identifiers anywhere without rewriting the logic.
final delegate = ManagedAuthDelegate<User>(dbCtx);
final auth = AuthServer(delegate);
router
.route('/auth/token')
.link(() => AuthController(auth));
router
.route('/auth/code')
.link(() => AuthCodeController(auth));
Boilerplate-avoiding meta-programming increases productivity, avoids simple errors and makes sure your API handles errors correctly and consistently.
@Operation.put('id')
Future<Response> updateTeam(
@Bind.path('id') int teamID,
@Bind.body() Team team,
@Bind.header('x-required-header') String requiredHeader,
{@Bind.query('optional_timestamp') DateTime timestamp}) {
return Response.ok(team);
}
Aqueduct was built to be tested. Know that your code works from end-to-end without fragile mocking. Use continuous integration tools like TravisCI with ease.
test('GET /teams returns 200 and list of teams', () async {
final response = await agent.get('/teams');
expectResponse(
response,
200,
body: everyElement({
'id': greaterThan(0),
'name': isNotNull
}));
});
Powerful reflection and static analysis tools allow you to automatically generate OpenAPI 3 documents from your source code. Generate client integration code and deploy first class documentation without extra effort.
openapi: "3.0.0"
info:
version: 1.0.0
title: Aqueduct API
paths:
/aqueduct:
...
components:
schemas:
...