From 4369c52a288f6d7b9ef2c92d934b070d89622653 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Tue, 4 Sep 2018 20:57:39 -0400 Subject: [PATCH 1/6] Begin update for 2.x --- bin/dev.dart | 2 +- lib/src/routes/routes.dart | 4 ++-- pubspec.yaml | 21 ++++++++++----------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/bin/dev.dart b/bin/dev.dart index 5514cc7b..fad79719 100644 --- a/bin/dev.dart +++ b/bin/dev.dart @@ -8,7 +8,7 @@ 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()..lazyParseBodies = true; + var app = new Angel(); await app.configure(configureServer); hierarchicalLoggingEnabled = true; app.logger = new Logger('angel'); diff --git a/lib/src/routes/routes.dart b/lib/src/routes/routes.dart index 43206d9a..be32ed56 100644 --- a/lib/src/routes/routes.dart +++ b/lib/src/routes/routes.dart @@ -39,11 +39,11 @@ AngelConfigurer configureServer(FileSystem fileSystem) { fileSystem, source: fileSystem.directory('web'), ); - app.use(vDir.handleRequest); + app.fallback(vDir.handleRequest); } // Throw a 404 if no route matched the request. - app.use(() => throw new AngelHttpException.notFound()); + app.fallback((req, res) => throw new AngelHttpException.notFound()); // Set our application up to handle different errors. // diff --git a/pubspec.yaml b/pubspec.yaml index d18a39f3..78a1f47d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,16 +5,15 @@ environment: sdk: '>=2.0.0-dev <3.0.0' homepage: https://github.com/angel-dart/angel dependencies: - angel_auth: ^1.1.0 # Supports stateless authentication via JWT - angel_configuration: ^1.2.0 # Loads application configuration, along with support for .env files. - angel_cors: ^1.0.0 # CORS support - angel_framework: ^1.1.0 # The core server library. - angel_jael: ^1.0.0 # Server-side templating engine - angel_static: ^1.3.0 # Static file server - angel_validate: ^1.0.0 # Allows for validation of input data - dart2_constant: ^1.0.0 # For backwards compatibility. + angel_auth: ^2.0.0-alpha # Supports stateless authentication via JWT + angel_configuration: ^2.0.0 # Loads application configuration, along with support for .env files. + #angel_cors: ^1.0.0 # CORS support + angel_framework: ^2.0.0-alpha # The core server library. + #angel_jael: ^1.0.0 # Server-side templating engine + angel_static: ^2.0.0-alpha # Static file server + angel_validate: ^2.0.0-alpha # Allows for validation of input data dev_dependencies: - angel_hot: ^1.1.0 # Hot-reloading support. :) - angel_test: ^1.1.0 # Utilities for testing Angel servers. + #angel_hot: ^1.1.0 # Hot-reloading support. :) + angel_test: ^2.0.0-alpha # Utilities for testing Angel servers. io: ^0.3.2 - test: ^0.12.13 + test: ^1.0.0 From de1d0c6dd049fba7cc0325f5282f1e668fb21205 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Tue, 4 Sep 2018 21:10:18 -0400 Subject: [PATCH 2/6] Require package:angel_production --- bin/prod.dart | 47 ++--------------------------------------------- pubspec.yaml | 1 + 2 files changed, 3 insertions(+), 45 deletions(-) diff --git a/bin/prod.dart b/bin/prod.dart index d805b24c..01d40d05 100644 --- a/bin/prod.dart +++ b/bin/prod.dart @@ -1,47 +1,4 @@ -import 'dart:io'; -import 'dart:isolate'; import 'package:angel/angel.dart'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:logging/logging.dart'; +import 'package:angel_production/angel_production.dart'; -const String hostname = '127.0.0.1'; -const int port = 3000; - -void main() { - // Start a server instance in multiple isolates. - - for (int id = 0; id < Platform.numberOfProcessors; id++) - Isolate.spawn(isolateMain, id); - - isolateMain(Platform.numberOfProcessors); -} - -void isolateMain(int id) { - var app = new Angel(); - - app.configure(configureServer).then((_) async { - // In production, we'll want to log errors to a file. - // Alternatives include sending logs to a service like Sentry. - hierarchicalLoggingEnabled = true; - app.logger = new Logger('angel') - ..onRecord.listen((rec) { - if (rec.error == null) { - stdout.writeln(rec); - } else { - var err = rec.error; - if (err is AngelHttpException && err.statusCode != 500) return; - var sink = stderr; - sink..writeln(rec)..writeln(rec.error)..writeln(rec.stackTrace); - } - }); - - // Passing `startShared` to the constructor allows us to start multiple - // instances of our application concurrently, listening on a single port. - // - // This effectively lets us multi-thread the application. - var http = new AngelHttp.custom(app, startShared); - var server = await http.startServer(hostname, port); - print( - 'Instance #$id listening at http://${server.address.address}:${server.port}'); - }); -} +main(List args) => new Runner('angel', configureServer).run(args); diff --git a/pubspec.yaml b/pubspec.yaml index 78a1f47d..8a7c097a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,6 +10,7 @@ dependencies: #angel_cors: ^1.0.0 # CORS support angel_framework: ^2.0.0-alpha # The core server library. #angel_jael: ^1.0.0 # Server-side templating engine + angel_production: ^1.0.0-alpha angel_static: ^2.0.0-alpha # Static file server angel_validate: ^2.0.0-alpha # Allows for validation of input data dev_dependencies: From 350e538b2b370e1a808c44f1ee9d2f310b656c89 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Tue, 2 Oct 2018 13:10:56 -0400 Subject: [PATCH 3/6] Add angel_hot --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 8a7c097a..ef26cd25 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: angel_static: ^2.0.0-alpha # Static file server angel_validate: ^2.0.0-alpha # Allows for validation of input data dev_dependencies: - #angel_hot: ^1.1.0 # Hot-reloading support. :) + angel_hot: ^2.0.0 # Hot-reloading support. :) angel_test: ^2.0.0-alpha # Utilities for testing Angel servers. io: ^0.3.2 test: ^1.0.0 From 59e904ddddb2df447819257d920f410ecc2bd2c0 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Tue, 2 Oct 2018 13:11:10 -0400 Subject: [PATCH 4/6] Remove CORS --- lib/src/routes/routes.dart | 4 ---- pubspec.yaml | 1 - 2 files changed, 5 deletions(-) diff --git a/lib/src/routes/routes.dart b/lib/src/routes/routes.dart index be32ed56..bd6baf36 100644 --- a/lib/src/routes/routes.dart +++ b/lib/src/routes/routes.dart @@ -1,7 +1,6 @@ /// This app's route configuration. library angel.src.routes; -import 'package:angel_cors/angel_cors.dart'; import 'package:angel_framework/angel_framework.dart'; import 'package:angel_static/angel_static.dart'; import 'package:file/file.dart'; @@ -14,9 +13,6 @@ import 'controllers/controllers.dart' as controllers; /// * https://github.com/angel-dart/angel/wiki/Requests-&-Responses AngelConfigurer configureServer(FileSystem fileSystem) { return (Angel app) async { - // Enable CORS - app.use(cors()); - // Typically, you want to mount controllers first, after any global middleware. await app.configure(controllers.configureServer); diff --git a/pubspec.yaml b/pubspec.yaml index ef26cd25..598e5879 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,6 @@ homepage: https://github.com/angel-dart/angel dependencies: angel_auth: ^2.0.0-alpha # Supports stateless authentication via JWT angel_configuration: ^2.0.0 # Loads application configuration, along with support for .env files. - #angel_cors: ^1.0.0 # CORS support angel_framework: ^2.0.0-alpha # The core server library. #angel_jael: ^1.0.0 # Server-side templating engine angel_production: ^1.0.0-alpha From bb088c345dacafcdfdab47d7c261666571e5afe5 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sat, 10 Nov 2018 16:56:41 -0500 Subject: [PATCH 5/6] Rename views, re-enable Jael --- pubspec.yaml | 2 +- views/{error.jl => error.jael} | 0 views/{hello.jl => hello.jael} | 0 views/{layout.jl => layout.jael} | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename views/{error.jl => error.jael} (100%) rename views/{hello.jl => hello.jael} (100%) rename views/{layout.jl => layout.jael} (100%) diff --git a/pubspec.yaml b/pubspec.yaml index 598e5879..18f192f5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,7 +8,7 @@ dependencies: angel_auth: ^2.0.0-alpha # 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_jael: ^1.0.0 # Server-side templating engine + angel_jael: ^2.0.0 # Server-side templating engine angel_production: ^1.0.0-alpha angel_static: ^2.0.0-alpha # Static file server angel_validate: ^2.0.0-alpha # Allows for validation of input data diff --git a/views/error.jl b/views/error.jael similarity index 100% rename from views/error.jl rename to views/error.jael diff --git a/views/hello.jl b/views/hello.jael similarity index 100% rename from views/hello.jl rename to views/hello.jael diff --git a/views/layout.jl b/views/layout.jael similarity index 100% rename from views/layout.jl rename to views/layout.jael From f9584c5310265411642a78ce603b988769e6d874 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Wed, 14 Nov 2018 02:18:56 -0500 Subject: [PATCH 6/6] Fix includes in views --- pubspec.yaml | 2 +- views/error.jael | 2 +- views/hello.jael | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 18f192f5..2b437aab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel -description: An easily-extensible web server framework in Dart. +description: An app that's going to be amazing pretty soon. publish_to: none # Ensure we don't accidentally publish our private code! ;) environment: sdk: '>=2.0.0-dev <3.0.0' diff --git a/views/error.jael b/views/error.jael index a3850ae5..1e93df46 100644 --- a/views/error.jael +++ b/views/error.jael @@ -1,4 +1,4 @@ - +
{{ message }}
diff --git a/views/hello.jael b/views/hello.jael index aeb5867c..7ca6b8af 100644 --- a/views/hello.jael +++ b/views/hello.jael @@ -1,4 +1,4 @@ - +
Angel