diff --git a/.vscode/launch.json b/.vscode/launch.json index 2c69cf0..a172648 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,7 +12,10 @@ "name": "Production Server", "type": "dart", "request": "launch", - "program": "${workspaceRoot}/bin/prod.dart" + "program": "${workspaceRoot}/bin/prod.dart", + "env": { + "ANGEL_ENV": "production" + } } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 0479cc0..0000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "0.1.0", - "command": "pub", - "isShellCommand": true, - "echoCommand": true, - "showOutput": "always", - "tasks": [ - { - "taskName": "pub:build", - "suppressTaskName": true, - "args": [ - "build" - ] - }, - { - "taskName": "pub:serve", - "showOutput": "silent", - "suppressTaskName": true, - "isBackground": true, - "args": [ - "serve" - ] - } - ] -} \ No newline at end of file diff --git a/README.md b/README.md index aff56f6..82ae3b4 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,25 @@ -[![The Angel Framework](https://angel-dart.github.io/assets/images/logo.png)](https://angel-dart.github.io) +[![The Angel Framework](https://angel-dart.github.io/assets/images/logo.png)](https://angel-dart.dev) [![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/angel_dart/discussion) [![Pub](https://img.shields.io/pub/v/angel_framework.svg)](https://pub.dartlang.org/packages/angel_framework) [![Build status](https://travis-ci.org/angel-dart/framework.svg?branch=master)](https://travis-ci.org/angel-dart/framework) ![License](https://img.shields.io/github/license/angel-dart/framework.svg) -**A batteries-included, full-stack Web server framework for Dart.** +**A polished, production-ready backend framework in Dart.** ----- +## About +Angel is a full-stack Web framework in Dart. It aims to +streamline development by providing many common features +out-of-the-box in a consistent manner. -[Wiki (in-depth documentation)](https://github.com/angel-dart/angel/wiki) - -[API Documentation](http://www.dartdocs.org/documentation/angel_common/latest) - -[Roadmap](https://github.com/angel-dart/roadmap/blob/master/ROADMAP.md) - -[File an Issue](https://github.com/angel-dart/roadmap/issues) - -[Awesome Angel :fire:](https://github.com/angel-dart/awesome-angel) - - - -Like what you see? Please lend us a star! :star: - -## Newest Tutorials -* [Dependency Injection Patterns with Angel 2](https://thosakwe.com/dependency-injection-patterns-in-angel-2/) -* [Angel 2.0.0 is Almost Here - What it Means for You](https://thosakwe.com/new-features-coming-to-angel-in-version-2-0-0/) -* [GraphQL is coming to Angel (and Dart)](https://thosakwe.com/graphql-is-coming-to-angel-and-dart/) +With features like the following, Angel is the all-in-one framework you should choose to build your next project: +* [GraphQL Support](https://github.com/angel-dart/graphql) +* [PostgreSQL ORM](https://github.com/angel-dart/orm) +* [Dependency Injection](https://docs.angel-dart.dev/guides/dependency-injection) +* And [much more](https://github.com/angel-dart)... ## Installation & Setup -*Having errors with a fresh Angel installation? See [here](https://angel-dart.gitbook.io/angel/the-basics/installation) for help.* Once you have [Dart](https://www.dartlang.org/) installed, bootstrapping a project is as simple as running a few shell commands: @@ -51,17 +41,18 @@ You can even have your server run and be *hot-reloaded* on file changes: dart --observe bin/dev.dart ``` -Next, check out the [detailed documentation](https://angel-dart.gitbook.io/angel) to learn to flesh out your project. +Next, check out the [detailed documentation](https://docs.angel-dart.dev/v/2.x) to learn to flesh out your project. -## 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://angel-dart.gitbook.io/angel/the-basics/middleware) -* [Dependency Injection](https://angel-dart.gitbook.io/angel/the-basics/dependency-injection) -* [Strongly-typed ORM](https://github.com/angel-dart/orm) -* And [much more](https://github.com/angel-dart)... +## Examples and Documentation +Visit the [documentation](https://docs.angel-dart.dev/v/2.x) +for dozens of guides and resources, including video tutorials, +to get up and running as quickly as possible with Angel. -## Basic Example -Examples and complete projects can be found here: +Examples and complete projects can be found +[here](https://github.com/angel-dart/examples-v2). + + +You can also view the [API Documentation](http://www.dartdocs.org/documentation/angel_framework/latest). + +There is also an [Awesome Angel :fire:](https://github.com/angel-dart/awesome-angel) list. -https://github.com/angel-dart/examples-v2 diff --git a/bin/dev.dart b/bin/dev.dart index 802864a..a2c4df3 100644 --- a/bin/dev.dart +++ b/bin/dev.dart @@ -8,17 +8,19 @@ import 'package:logging/logging.dart'; main() async { // Watch the config/ and web/ directories for changes, and hot-reload the server. - var hot = new HotReloader(() async { - var app = new Angel(reflector: MirrorsReflector()); + hierarchicalLoggingEnabled = true; + + var hot = HotReloader(() async { + var logger = Logger.detached('{{angel}}')..onRecord.listen(prettyLog); + var app = Angel(logger: logger, reflector: MirrorsReflector()); await app.configure(configureServer); - hierarchicalLoggingEnabled = true; - app.logger = new Logger.detached('{{angel}}')..onRecord.listen(prettyLog); return app; }, [ - new Directory('config'), - new Directory('lib'), + Directory('config'), + Directory('lib'), ]); var server = await hot.startServer('127.0.0.1', 3000); - print('{{angel}} server listening at http://${server.address.address}:${server.port}'); + print( + '{{angel}} server listening at http://${server.address.address}:${server.port}'); } diff --git a/bin/prod.dart b/bin/prod.dart index b7f1728..db0ec67 100644 --- a/bin/prod.dart +++ b/bin/prod.dart @@ -1,4 +1,5 @@ import 'package:angel/angel.dart'; +import 'package:angel_container/mirrors.dart'; import 'package:angel_production/angel_production.dart'; // NOTE: By default, the Runner class does not use the `MirrorsReflector`, or any @@ -11,7 +12,7 @@ import 'package:angel_production/angel_production.dart'; // * Use of Controllers, via @Expose() or @ExposeWS() // * Use of dependency injection into constructors, whether in controllers or plain `container.make` calls // * Use of the `ioc` function in any route -// +// // The `MirrorsReflector` from `package:angel_container/mirrors.dart` is by far the most convenient pattern, // so use it if possible. // @@ -24,4 +25,6 @@ import 'package:angel_production/angel_production.dart'; // so in the meantime, visit the Angel chat for further questions: // // https://gitter.im/angel_dart/discussion -main(List args) => Runner('{{angel}}', configureServer).run(args); +main(List args) => + Runner('{{angel}}', configureServer, reflector: MirrorsReflector()) + .run(args); diff --git a/lib/src/config/plugins/orm.dart b/lib/src/config/plugins/orm.dart index 3e616b9..955056b 100644 --- a/lib/src/config/plugins/orm.dart +++ b/lib/src/config/plugins/orm.dart @@ -10,7 +10,7 @@ Future configureServer(Angel app) async { await connection.open(); app - ..container.registerSingleton(PostgreSQLExecutor(connection)) + ..container.registerSingleton(PostgreSqlExecutor(connection)) ..shutdownHooks.add((_) => connection.close()); } diff --git a/lib/src/routes/routes.dart b/lib/src/routes/routes.dart index 2c5ba56..8e494d1 100644 --- a/lib/src/routes/routes.dart +++ b/lib/src/routes/routes.dart @@ -56,7 +56,7 @@ AngelConfigurer configureServer(FileSystem fileSystem) { // Read the following two sources for documentation: // * https://medium.com/the-angel-framework/serving-static-files-with-the-angel-framework-2ddc7a2b84ae // * https://github.com/angel-dart/static - if (!app.isProduction) { + if (!app.environment.isProduction) { var vDir = VirtualDirectory( app, fileSystem, @@ -75,15 +75,15 @@ AngelConfigurer configureServer(FileSystem fileSystem) { var oldErrorHandler = app.errorHandler; app.errorHandler = (e, req, res) async { - if (!req.accepts('text/html', strict: true)) - return await oldErrorHandler(e, req, res); - else { - if (e.statusCode == 404) { - return await res + if (req.accepts('text/html', strict: true)) { + if (e.statusCode == 404 && req.accepts('text/html', strict: true)) { + await res .render('error', {'message': 'No file exists at ${req.uri}.'}); + } else { + await res.render('error', {'message': e.message}); } - - return await res.render('error', {'message': e.message}); + } else { + return await oldErrorHandler(e, req, res); } }; }; diff --git a/pubspec.yaml b/pubspec.yaml index c08b96d..a049fff 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ homepage: https://github.com/angel-dart/angel dependencies: angel_auth: ^2.0.0 # Supports stateless authentication via JWT angel_configuration: ^2.0.0 # Loads application configuration, along with support for .env files. - angel_framework: ^2.0.0-alpha # The core server library. + angel_framework: ^2.0.0-rc.0 # The core server library. angel_jael: ^2.0.0 # Server-side templating engine angel_migration: ^2.0.0-alpha # Migration runtime support angel_orm: ^2.0.0-dev # Migration runtime support