2016-12-27 14:28:48 +00:00
[![The Angel Framework ](https://angel-dart.github.io/images/logo.png )](https://angel-dart.github.io)
2017-02-02 20:48:25 +00:00
[![Gitter ](https://img.shields.io/gitter/room/nwjs/nw.js.svg )](https://gitter.im/angel_dart/discussion)
2017-04-10 13:52:23 +00:00
[![version: v1.0.0 ](https://img.shields.io/badge/pub-v1.0.0-brightgreen.svg )](https://pub.dartlang.org/packages/angel_common)
2016-12-21 20:34:04 +00:00
2017-05-05 22:02:48 +00:00
**Fill out the [v1.0.0 survey ](https://docs.google.com/forms/d/e/1FAIpQLSfEgBNsOoi_nYZMmg2IAGyMv1nNaa6B3kUk3QdNJU5987ucVA/viewform?usp=sf_link ) now!!!**
2017-04-02 20:32:44 +00:00
[Wiki (in-depth documentation) ](https://github.com/angel-dart/angel/wiki )
2016-06-21 23:39:09 +00:00
2016-12-21 20:43:29 +00:00
[API Documentation ](http://www.dartdocs.org/documentation/angel_common/latest )
2016-12-21 19:41:23 +00:00
[Roadmap ](https://github.com/angel-dart/roadmap/blob/master/ROADMAP.md )
[File an Issue ](https://github.com/angel-dart/roadmap/issues )
2017-03-11 03:40:14 +00:00
2017-06-13 00:55:20 +00:00
[Awesome Angel :fire: ](https://github.com/angel-dart/awesome-angel )
2017-04-02 20:59:58 +00:00
**The Dart server framework that's ready for showtime.**
2017-04-02 20:36:48 +00:00
2017-04-02 20:59:58 +00:00
Angel is a full-featured server-side Web application framework for the Dart programming language. It strives to be a flexible, extensible system, to be easily scalable, and to allow as much code to be shared between clients and servers as possible. Ultimately, I believe that this approach will shorten the time it takes to build a full-stack Web application, from start to finish. [Read more... ](https://medium.com/the-angel-framework/announcing-angel-v1-0-0-beta-46dfb4aa8afe )
2017-04-02 20:36:48 +00:00
2017-04-02 21:08:10 +00:00
Like what you see? Please lend us a star. :star:
2017-06-05 17:01:45 +00:00
## Newest Tutorials
* [Serving Static Files ](https://medium.com/the-angel-framework/serving-static-files-with-the-angel-framework-2ddc7a2b84ae )
* Use With Angular2 ([article](https://dart.academy/using-angel-with-angular2/) | [video ](https://www.youtube.com/watch?v=O8tCXj_lljY&feature=youtu.be ))
* [Instant REST API's - Intro to Services ](https://medium.com/the-angel-framework/instant-rest-apis-and-more-an-introduction-to-angel-services-b843f3187f67 )
2017-03-23 11:23:16 +00:00
## Installation & Setup
2017-04-02 20:32:03 +00:00
*Having errors with a fresh Angel installation? See [here ](https://github.com/angel-dart/angel/wiki/Installation-&-Setup ) for help.*
Once you have [Dart ](https://www.dartlang.org/ ) installed, bootstrapping a project is as simple as running one shell command:
2017-04-02 20:28:22 +00:00
2017-04-02 20:32:03 +00:00
Install the [Angel CLI ](https://github.com/angel-dart/cli ):
2017-04-02 20:28:22 +00:00
```bash
pub global activate angel_cli
2017-04-02 20:32:03 +00:00
```
Bootstrap a project:
```bash
2017-04-02 20:28:22 +00:00
angel init hello
```
2017-04-02 20:32:03 +00:00
2017-04-02 20:43:55 +00:00
You can even have your server run and be *live-reloaded* on file changes:
2017-04-02 20:38:20 +00:00
2017-06-10 15:45:59 +00:00
```bash
2017-06-10 15:45:48 +00:00
dart bin/server.dart
2017-04-02 20:38:20 +00:00
```
2017-04-02 20:32:03 +00:00
Next, check out the [detailed documentation ](https://github.com/angel-dart/angel/wiki ) to learn to flesh out your project.
2017-04-02 20:59:58 +00:00
## Features
With features like the following, Angel is the all-in-one framework you should choose to build your next project:
* [Advanced, Modular Routing ](https://github.com/angel-dart/route )
* [Middleware ](https://github.com/angel-dart/angel/wiki/Middleware )
* [Dependency Injection ](https://github.com/angel-dart/angel/wiki/Dependency-Injection )
* And [much more ](https://github.com/angel-dart )...
2017-04-02 20:32:03 +00:00
2017-04-02 20:59:58 +00:00
## Basic Example
More examples and complete projects can be found in the [angel-example ](https://github.com/angel-example ) organization.
The following is an [explosive application ](https://github.com/angel-example/explode ) complete with a REST API and
2017-04-02 21:08:31 +00:00
WebSocket support. It interacts with a MongoDB database, and reads configuration automatically from a `config/<ANGEL-ENV-NAME>.yaml` file. Templates are rendered with Mustache, and all responses are compressed via GZIP.
2017-04-02 20:59:58 +00:00
2017-04-02 21:13:54 +00:00
**All in just about 20 lines of actual code.**
2017-04-02 21:08:52 +00:00
2017-04-02 20:59:58 +00:00
```dart
2017-04-02 21:05:24 +00:00
import 'dart:async';
2017-04-02 20:59:58 +00:00
import 'package:angel_common/angel_common.dart';
import 'package:angel_websocket/server.dart';
import 'package:mongo_dart/mongo_dart.dart';
main() async {
var app = await createServer();
var server = await app.startServer(InternetAddress.LOOPBACK_IP_V4, 8080);
print('Angel listening at http://${server.address.address}:${server.port}');
}
Future< Angel > createServer() async {
2017-04-03 11:17:34 +00:00
// New instance...
var app = new Angel();
2017-04-02 20:59:58 +00:00
// Configuration
await app.configure(loadConfigurationFile());
2017-04-02 21:05:24 +00:00
await app.configure(mustache());
2017-04-02 20:59:58 +00:00
Db db = new Db();
await db.open(app.mongodb_url);
app.container.singleton(db); // Add to DI
// Routes
app.get('/foo', (req, res) => res.render('hello'));
app.post('/query', (Db db) async {
// Db is an injected dependency here :)
return await db.collection('foo').find().toList();
});
// Services (which build REST API's and are broadcasted over WS)
app.use('/bombs', new MongoService(db.collection('bombs')));
app.use('/users', new MongoService(db.collection('users')));
app.use('/explosions', new AnonymousService(create: (data, [params]) => data));
// Setup WebSockets, add GZIP, etc.
2017-04-05 18:45:29 +00:00
await app.configure(new AngelWebSocket());
2017-04-02 20:59:58 +00:00
app.responseFinalizers.add(gzip());
return app;
}
```
2017-04-02 20:32:03 +00:00
2017-06-05 17:02:28 +00:00
## Get Social
Join an activate chat about the Angel Framework, or seek assistance: https://gitter.im/angel_dart/discussion