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/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/lib/src/routes/routes.dart b/lib/src/routes/routes.dart index 43206d9a..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); @@ -39,11 +35,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..2b437aab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,20 +1,19 @@ 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' 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_framework: ^2.0.0-alpha # The core server library. + 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 dev_dependencies: - angel_hot: ^1.1.0 # Hot-reloading support. :) - angel_test: ^1.1.0 # Utilities for testing Angel servers. + angel_hot: ^2.0.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 diff --git a/views/error.jl b/views/error.jael similarity index 70% rename from views/error.jl rename to views/error.jael index a3850ae5..1e93df46 100644 --- a/views/error.jl +++ b/views/error.jael @@ -1,4 +1,4 @@ - +
{{ message }}
diff --git a/views/hello.jl b/views/hello.jael similarity index 68% rename from views/hello.jl rename to views/hello.jael index aeb5867c..7ca6b8af 100644 --- a/views/hello.jl +++ b/views/hello.jael @@ -1,4 +1,4 @@ - +
Angel
diff --git a/views/layout.jl b/views/layout.jael similarity index 100% rename from views/layout.jl rename to views/layout.jael