
Show HN: Aqueduct – Dart on the Server - jcstk
https://aqueduct.io
======
jcstk
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.

One thing that makes Aqueduct really interesting is that it runs the
application on a few isolated-memory threads. This is a concept interpreted
from the Erlang/Elixir that leverages Dart 'Isolate's. (Here's some
documentation on that:
[https://aqueduct.io/docs/http/structure/](https://aqueduct.io/docs/http/structure/))

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

~~~
jcstk
(And we'd also really love to hear any critical feedback.)

~~~
zengid
Whats your perspective of the activity around the Dart VM? Is Google actively
maintaining it? As a JS dev I always wrote it off as being a non-starter, but
your project has intrigued me to taking a second look at the VM. Thanks!

~~~
jcstk
Good question - yeah, the VM is actively maintained. All of the tooling for
the Dart ecosystem runs on the VM, Flutter is a Dart VM project, too.

The changelog [1] always has a few entries for the Dart VM with each version,
but it's quite clear from using it daily that much more is happening. Some
notable recent improvements have been asynchronous breakpoints that are
integrated in IntelliJ's debugger and some optimizations for sending messages
across isolates.

1: [https://github.com/dart-
lang/sdk/blob/master/CHANGELOG.md](https://github.com/dart-
lang/sdk/blob/master/CHANGELOG.md)

~~~
markdog12
> notable recent improvements have been asynchronous breakpoints that are
> integrated in IntelliJ's debugger and some optimizations for sending
> messages across isolates.

Where did you get that info? I haven't seen it in the changelog. Is message
passing using structured cloning?

~~~
jcstk
Just through observation. Breakpoints just started to work and a pesky race
condition between isolates became reproducible.

------
pritambarhate
Looks promising. But didn't see anywhere in the docs how does this work. *
What's the underlying server? * Does it transpile to Node.js? * How does the
third party module system work? * Which are other readymade libraries that can
be used with this?

~~~
jcstk
It runs directly on the Dart VM, which has its own HTTP server implementation.
That's the interesting thing about the Dart VM - it's a C++ executable with no
ties to JS. Third party modules may be provided by through Dart's package
manager, [https://pub.dartlang.org](https://pub.dartlang.org).

It's command-line tool runs the application, but there isn't much from
stopping you from just using the `dart` command line tool and a Dart script to
start it.

edit: Basically, you can run this on any machine that can install Dart.

------
malkia
I love flutter/dart, and have some little experience with Java +
servers/microservices... So my question is how is GC trashing handled? e.g. if
it becomes > some percentage of the running time are isolates
"killed/restarted" (if that makes senses, or the whole process)?

~~~
jcstk
When running `wrk` to do performance testing and monitoring in Observatory [1]
and with anything we have in production, I haven't seen an Isolate or the
process ever die. This may be a question better suited for the Dart VM team,
I'll see if I can't ping someone.

And yeah, as a native iOS developer for many years, I finally sat down and
built something in Flutter this weekend and really liked it.

1: [https://dart-lang.github.io/observatory/](https://dart-
lang.github.io/observatory/)

------
ezekg
This looks great. I'm still a little fuzzy on Dart--does it still compile to
JS or is it it's own language now?

~~~
jcstk
So Dart has a few different compilation targets: JavaScript for building
front-end web apps and the Dart VM [1]. There's also some work being done for
other compilation targets, specifically for faster development cycles when
doing front-end web stuff.

The interesting thing about the Dart VM is there's no JavaScript at all. You
can even link to C and C++ code from Dart.

1: Here's a discussion on how the Dart VM is implemented:
[https://groups.google.com/a/dartlang.org/forum/#!topic/misc/...](https://groups.google.com/a/dartlang.org/forum/#!topic/misc/1cV_PAXQPPQ))

------
adrianlmm
There is no way to serve static files, mmmmm.

~~~
jcstk
Sure there is:
[http://aqueduct.io/docs/http/serving_files/](http://aqueduct.io/docs/http/serving_files/)

~~~
adrianlmm
Not convenient, you'll have to define a route for every single file instead of
having a folder serving static content.

~~~
jcstk
Hmmm, no, that's not accurate. You specify a folder serving static content and
the HTTP path is resolved against that folder. e.g.

    
    
      router.route("/*").pipe(new HTTPFileController("web/");
      router.route("/files/*").pipe(new HTTPFileController("something_else/");
    

An HTTP request for /foo.html returns web/foo.html. An HTTP request for
/foo/bar.html returns web/foo/bar.html.

An HTTP request for /files/xyz.jpg returns the something_else/xyz.jpg.

If the HTTP path is a directory, then index.html is automatically appended to
it. This is a brief overview of the referenced documentation above.

~~~
adrianlmm
You still need to manually open the file, read it and add it to the body of
the response, to impractical IMHO.

Never mind, I was readding wrong.

