Code Monkey home page Code Monkey logo

aqueduct's Introduction

Aqueduct

OSX/Linux Build Status Windows Build status codecov

Slack

Aqueduct is a modern Dart HTTP server framework. The framework is composed of libraries for handling and routing HTTP requests, object-relational mapping (ORM), authentication and authorization (OAuth 2.0 provider) and documentation (OpenAPI). These libraries are used to build scalable REST APIs that run on the Dart VM.

If this is your first time viewing Aqueduct, check out the tour.

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 IntelliJ IDE, Atom or Visual Studio Code. All three IDEs have a Dart plugin. For IntelliJ IDEA users, there are file and code templates for Aqueduct.

Tutorials, Documentation and Examples

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 ever-expanding repository of Aqueduct examples is here.

aqueduct's People

Contributors

anachlas avatar bartonhammond avatar benbarbersmith avatar caffeineflo avatar deathman92 avatar erikist avatar jadengis avatar jesseblack82 avatar jodinathan avatar joeconwaystk avatar kevmoo avatar lieblb avatar marcussmith avatar mhelmetag avatar pschiffmann avatar reductions avatar robertblackhart avatar sergeshkurko avatar stablekernel-admin avatar sudolibre avatar terrencepreilly avatar tgercek avatar xvld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aqueduct's Issues

README.md doesn't tell what to expect after server start

I followed the Getting Started, and after doing the aqueduct create -n my_project I followed the instructions in the README.md. All went well (on one of my Macs), but after starting my new server, I didn't know what to expect. When I tried just localhost:8000 in my browser, I got an empty page. If I tried localhost:8000/users, I got {"error":"No authorization header."}. At least some response. I think the README.md should give a hint about what one have to provide next.

aqueduct quickstart not working

Just did the quickstart instructions and "aqueduct" is failing with following output:

D:\WORKSPACE\DART\aqueduct_playground>pub run aqueduct setup
Could not find bin\aqueduct.dart in package aqueduct.

My "path" environment setting is set for dart:

D:\WORKSPACE\DART>dart --version
Dart VM version: 1.20.0-dev.10.3 (Wed Oct 12 11:04:40 2016) on "windows_x64"

By activating "aqueduct", pub is telling me aqueduct is already activated:

D:\WORKSPACE\DART>pub global activate aqueduct
Package aqueduct is currently active at version 0.9.0.
Resolving dependencies...

Also by checking my local packages, it seems under "bin" path is only a "test.dart" file:
aqueduct_package

Additional information
I also tried the alternative by just adding the dependency (1.0.2) in an empty project:

D:\WORKSPACE\DART\aqueduct_playground>pub get
Resolving dependencies...
Package aqueduct has no versions that match 1.0.2 derived from:

  • aqueduct_playground depends on version 1.0.2

It worked with "any" and still informs about a newer package version

D:\WORKSPACE\DART\aqueduct_playground>pub get
Resolving dependencies...

  • analyzer 0.27.3 (0.29.0 available)
  • aqueduct 0.9.0 (1.0.2 available)
    ...

The result is still the same, due to missing "aqueduct.dart" file under "bin" path. The terminal is being ran with "admin" priveleges.

Anyone with similar experiences on windows 64 bit?

Build authentication adapter

Allow a multi-stream auth adapter to handle authentication, not authenticated, and not signed events. Be able to plug into any part of the stream (pre router, between router/controller)

Automatically add foreign key to resultKeys for join queries

If a client specifies resultKeys for a subquery, and those resultKeys do not contain the foreign key back to the main query, then the resulting model graph cannot be paired. Omitting the foreign key from resultKeys should either (preferably) automatically add that key or throw an exception.

Replace request body parser

Currently uses outdated http_server, which has an issue of responding to requests when it fails, which makes no sense.

Allow for user-level authentication to read/write certain objects

I would imagine you could have a subclass of model controller that only deals with objects that have a userId property, and then in any get, put, or delete request it makes sure the authorization for the request matches the userId otherwise returning a 403. For post requests it could fill in the userId on the valueObject.

Error when creating a new project from command line on Windows 7

When I'm trying to create a new project from command line with the "aqueduct create" command, I'm getting an error on Windows 7.

Here is the output :

C:\Users\Aelayeb>aqueduct create -n web_dart
Fetching Aqueduct as:
  aqueduct: "any"
Determining Aqueduct template source...
ProcessException: Le fichier sp├®cifi├® est introuvable.

  Command: pub get --no-packages-dir

Tested on Windows 7 64bits.

Response.notFound() and 404, logging

In my generated test project I have commented out the .pipe(new Authorizer(authenticationServer)) on the line under .route("/users/[:id]") (in my lib/src/aque_test_sink.dart) so I won't get the {"error":"No authorization header."} when I try localhost:8000/users. Now I just get an empty page instead. I would have expected a 404. Do I have to provide something for a Response.notFound() to give me a visible 404 page?
What's the easiest way to insert logging lines into a file like lib/src/controller/user_controller.dart?

other db's ?

really nice framework.

anyone know if there is support for sql dialects, so that other databases can be targeted ?

maybe this is envisaged on the roadmap ?

Best practices for POST and related tests

Greetings:

A bit of a 2 part issue / question around the same topic...

1 - I may have missed documentation examples somewhere about this, but what I put together seems to be working. For a POST endpoint I'm just doing this inside my Controller class to get at the data I'm receiving:

await request.decodeBody();
Map body = request.requestBodyObject;

First question is, all good here?

2 - The main reason I'm asking is because I get major failure when I run this through a test case, unless I comment out the first line completely (decodeBody()). Here's the error:

Expected: 
	Status Code: 200
	Body: 'OK'
  Actual: TestResponse:<
	Status Code: 500
	Headers: x-frame-options: SAMEORIGIN
			 content-type: application/json; charset=utf-8
			 x-xss-protection: 1; mode=block
			 x-content-type-options: nosniff
			 server: aqueduct/1
			 content-length: 0
	Body: null>
   Which: Status Code 200 != 500

package:test                                       expect
test/facebook_controller_test.dart 38:7            main.<async>.<fn>.<fn>.<async>
dart:async                                         _SyncCompleter.complete
package:aqueduct/utilities/test_client.dart 279:5  TestRequest._executeRequest.<async>
dart:async                                         _SyncCompleter.complete
package:aqueduct/utilities/test_client.dart 354:3  TestResponse._decodeBody.<async>
===== asynchronous gap ===========================
dart:async                                         _Completer.completeError
test/facebook_controller_test.dart 39:6            main.<async>.<fn>.<fn>.<async>
dart:async                                         _SyncCompleter.complete
package:aqueduct/utilities/test_client.dart 279:5  TestRequest._executeRequest.<async>
dart:async                                         _SyncCompleter.complete
package:aqueduct/utilities/test_client.dart 354:3  TestResponse._decodeBody.<async>

The code comments in request.dart indicate the need to call decodeBody() first and it does work just fine on a deployed server, but the test fail is a bit of a nuisance requiring manual edits before running the test. Is this a bug or am I doing something wrong?

Also, I can't get any custom logging to work at all in my controller classes when running through a test case - everything from trying to log to a remote system like Rollbar through to just a standard print statement. That also works fine when deployed but just not when running a test. Any recommendations on how to approach that? The issue above was pretty tough to diagnose without having any logging capabilities in my Controller code during a test run.

Thanks in advance!

Documentation: Task List

  • Authentication
  • Database Migration
  • CORS Support
  • Testing
  • Using the Template tutorial
  • OpenAPI Specification generation
  • PersistentStore Implementations
  • Improve Tutorial Navigation
  • Deployment Options (Heroku, EC2)
  • Debugging Aqueduct Applications

more details terminal output message

I tried running and get this result

Resolving dependencies... 
Got dependencies!
Starting...
Server running.

it will be more better with message which port running and which api got hit by client.

Rename metadata for persistent entities

RelationshipAttribute -> Relationship
Attributes -> ???

Attributes now means something slightly different - an entity has attributes and relationships, which are properties. Even a singular Attribute may be ok.

Evaluate generic result container

Currently, async operations (especially DB related stuff) throw exceptions on failure. Investigate whether returning a tuple-like structure is a better approach. It would require more hands-on approach within request handlers, but it'd be more explicit and less magical. Example result object:

class FailableOperationResult<T> implements Serializable {
  T value;
  dynamic error;
  int statusCode;
  String message;

  bool get didFail {
    return error != null;
  }

  dynamic asSerializable() {
    return {"error" : message};
  }
}

Return URL format errors with better response code

If you pass the wrong type of value in a path param - a string when an int is expected - the exception thrown is not caught by the HttpController and yields a 500. Should return a 404. Example trace:

[SEVERE] 2016-01-27 15:45:47.605 monadart: HttpController: Uncaught error in request (/equipment/modes (1453927547602)
user-agent [Paw/2.2.9 (Macintosh; OS X/10.11.3) GCDHTTPRequest],connection [close],host [10.1.10.187:8000],authorization [Bearer SH5FMqBDXHJHzY2UKkJ09UYWa6yyzjSF],
): FormatException: Invalid radix-10 number
modes
#0 int._throwFormatException (dart:core-patch/integers_patch.dart:111)
#1 int._parse (dart:core-patch/integers_patch.dart:101)
#2 int.parse (dart:core-patch/integers_patch.dart:58)
#3 _LocalClassMirror._invoke (dart:mirrors-patch/mirrors_impl.dart:927)
#4 _LocalObjectMirror.invoke (dart:mirrors-patch/mirrors_impl.dart:363)
#5 ModelController.willProcessRequest (package:monadart/db/model_controller.dart:40:18)
#6 HttpController.processRequest.<processRequest_async_body> (package:monadart/base/http_controller.dart:253:7)
#7 Future.Future.microtask. (dart:async/future.dart:144)
#8 _microtaskLoop (dart:async/schedule_microtask.dart:43)
#9 _microtaskLoopEntry (dart:async/schedule_microtask.dart:52)
#10 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#11 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)

.

Make ORM modular / separate project

This came about in a discussion on slack where I was talking to the Jaguar folks, who are also creating another server side Dart framework.

The Dart ecosystem is still small, and it would be great to have more code sharing going on. It is perhaps not realistic that everyone is going to adopt the same server side framework - but it would be great if more code sharing and collaboration could happen.

Things like the ORM module would seem to make sense as a standalone project.

Just a thought...

Implement right joins

Makes sense to go up the chain, too, to find owners of things. E.g.

var equipmentQuery = new EquipmentQuery()
  ..id = whereEqualTo(1)
  ..location = whereAnyMatch
  ..location.user = whereAnyMatch;

If equipment exists:
If location exists:
If user exists: Return equipment with location field populated with user field populated.
If user does not exist: Return equipment with location field populated with user field null.
If location does not exist: Return equipment with location field null.
If equipment does not exist: Return null

Make Application generic

Application should be generic with the PipelineType as the generic parameter instead of providing it as a property.

Add more documentation on CORS

Hello Joe @joeconwaystk :)

Here's Benjamin, we met at DartDev Summit, if you remember ;)

Now, after the summit, I'm trying to implement a little server with aqueduct.
But I'm not able to figure out how to do that CORS support.

There is some documentation here:
http://stablekernel.github.io/aqueduct/http/request_controller.html

I managed to come up with that:

EmailController() {
    if (policy.allowedOrigins == null) policy.allowedOrigins = [];

    policy.allowedOrigins
      ..add("http://fewo-birkennest.de/*");
}

And that:

@httpPost
Future<Response> sendEmail(@HTTPHeader("Origin") String origin) async {
}

If I try to make a post request with Postman to that url and debug the EmailController, the defined origin variable is not shown in intelli j watcher window.

Also, the request is allowed instead of blocked. Normally it should be blocked in this config, because localhost is not allowed.

But even if I fake the origin to something different with Postman , e.g. "http://chip.de", the request arrives at the sendEmail method.

Can you help me with this? :)

Return appropriate error code for invalid type in model object

Trying to assign a String to an int throws an exception that returns a 500, but this should be intercepted and turned into a 400.

Expected: Status Code: 400
Actual: <Instance of 'Response'>
Which: Response Body: {"error":"invalid input syntax for integer: "foo""}, Status Code Is Actually: 500

Allow resource controller endpoints to take query params as optional arguments

An endpoint could have optional arguments to automatically grab query parameters. These shouldn't impact routing or which handler gets the query parameters. A signature for a handler could then look like this:

@httpget
Future getThings({String location, String name}) {}

where name and location are names of query parameters (case insensitive) and if they exist, those arguments are populated.

Create API documentation intermediate file format

Documentation should be able to be generated entirely from metadata of router and resource controllers.This documentation should be in an intermediate format that can be converted to something like Postman or Swagger.

Add transactions to db layer

Should be able to submit queries as transactions and have mechanism for handling both failure and success cases.

Problems getting started with development on windows.

Hello,

I've been searching everywhere, but no luck. At the moment on my machine i have postgresql and aqueduct installed. The command line recognizes the 2 commands just fine, yet aqueduct keeps saying that i don't have PostgreSQL installed. Might this be a issue with aqueduct? Or somehting i may be doing wrong?

Thanks in advance

C:\WINDOWS\system32>psql -V
psql (PostgreSQL) 9.3.5

C:\WINDOWS\system32>aqueduct
Invalid command, options are: create, db, setup

C:\WINDOWS\system32>aqueduct setup
No psql found in PATH.

If you do not have PostgreSQL installed locally, you must do so to run tests in an Aqueduct application. For macOS users, download Postgres.app from http://postgresapp.com. Once installed, open the application at least once and add the following line to ~/.bash_profile:

    export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin

You may have to reload the shell you ran this command from after installation. For non-macOS users, you must install a local version of PostgreSQLand ensure the command line executable 'psql' is in your PATH.

Add WebSocket RequestController

A request controller that manages a persistent websocket and can be added as an event listener in a chain of request controllers.

Complex regex in route don't parse

Sample route that fails to parse.
/connected_systems/[:macAddress(^([0-9A-Z]{2}[-]){5}([0-9A-Z]{2})\$)]

Invalid argument(s): invalid resource pattern segment macAddress(^(0-9A-Z{2}-){5}(0-9A-Z{2})$), available formats are the following: literal, *, :name, :name(pattern)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.