From 2ea69f2cde62e9bd7bde731e46ec533b808d227e Mon Sep 17 00:00:00 2001 From: Patrick Stewart Date: Sat, 12 Oct 2024 19:17:24 -0700 Subject: [PATCH] Refactor: changing namespace, imports, re-branding --- packages/auth/CHANGELOG.md | 4 +- packages/auth/README.md | 4 +- packages/auth/example/example.dart | 2 +- packages/auth/example/example1.dart | 5 +- packages/auth/example/example2.dart | 10 ++- packages/auth/lib/src/options.dart | 12 +-- packages/auth/lib/src/plugin.dart | 24 +++--- packages/auth/lib/src/popup_page.dart | 2 +- packages/auth/lib/src/strategies/local.dart | 6 +- packages/auth/lib/src/strategy.dart | 2 +- packages/auth/test/callback_test.dart | 6 +- packages/auth/test/local_test.dart | 10 ++- packages/auth/test/protect_cookie_test.dart | 2 +- packages/auth_oauth2/CHANGELOG.md | 2 +- packages/auth_oauth2/README.md | 6 +- packages/auth_oauth2/example/main.dart | 4 +- .../auth_oauth2/lib/protevus_auth_oauth2.dart | 4 +- packages/auth_twitter/example/example.dart | 4 +- .../lib/protevus_auth_twitter.dart | 6 +- packages/cache/README.md | 2 +- packages/client/CHANGELOG.md | 2 +- packages/client/README.md | 2 +- packages/client/example/example1.dart | 4 +- packages/client/lib/base_protevus_client.dart | 2 +- packages/client/test/all_test.dart | 2 +- packages/client/test/auth_test.dart | 5 +- packages/client/test/common.dart | 4 +- packages/core/container/container/README.md | 2 +- packages/core/exceptions/CHANGELOG.md | 2 +- packages/core/framework/CHANGELOG.md | 14 ++-- .../framework/example/http2/body_parsing.dart | 2 +- .../core/framework/example/http2/main.dart | 2 +- .../framework/example/http2/server_push.dart | 2 +- .../core/framework/lib/src/core/driver.dart | 2 +- packages/core/framework/lib/src/core/env.dart | 2 +- .../framework/lib/src/core/map_service.dart | 4 +- .../core/framework/lib/src/core/service.dart | 2 +- .../framework/lib/src/http2/angel_http2.dart | 2 +- .../core/framework/test/find_one_test.dart | 6 +- packages/core/framework/test/server_test.dart | 2 +- packages/core/mocking/test/all_test.dart | 2 +- packages/hot/README.md | 2 +- packages/jael/angel_jael/README.md | 4 +- packages/jinja/README.md | 2 +- packages/oauth2/CHANGELOG.md | 2 +- packages/orm/README.md | 4 +- packages/paginate/CHANGELOG.md | 2 +- packages/production/lib/src/runner.dart | 2 +- packages/security/CHANGELOG.md | 2 +- packages/seo/README.md | 8 +- packages/shelf/CHANGELOG.md | 4 +- packages/shelf/README.md | 14 ++-- packages/static/README.md | 2 +- packages/sync/README.md | 4 +- packages/test/CHANGELOG.md | 2 +- packages/test/README.md | 4 +- packages/validate/CHANGELOG.md | 2 +- packages/validate/README.md | 2 +- packages/validate/lib/server.dart | 7 +- packages/validate/lib/src/async.dart | 83 ++++++++++--------- packages/websocket/CHANGELOG.md | 4 +- packages/websocket/README.md | 6 +- packages/websocket/lib/server.dart | 2 +- packages/websocket/test/auth_test.dart | 2 +- 64 files changed, 179 insertions(+), 171 deletions(-) diff --git a/packages/auth/CHANGELOG.md b/packages/auth/CHANGELOG.md index 6dadefca..8e02de04 100644 --- a/packages/auth/CHANGELOG.md +++ b/packages/auth/CHANGELOG.md @@ -135,9 +135,9 @@ ## 2.0.0 * Made `AuthStrategy` generic. -* `AngelAuth.strategies` is now a `Map>`. +* `ProtevusAuth.strategies` is now a `Map>`. * Removed `AuthStrategy.canLogout`. -* Made `AngelAuthTokenCallback` generic. +* Made `ProtevusAuthTokenCallback` generic. ## 2.0.0-alpha diff --git a/packages/auth/README.md b/packages/auth/README.md index 5cf286a1..de2db458 100644 --- a/packages/auth/README.md +++ b/packages/auth/README.md @@ -18,7 +18,7 @@ Ensure you have read the [User Guide](https://protevus-docs.dukefirehawk.com/gui ```dart configureServer(Protevus app) async { - var auth = AngelAuth( + var auth = ProtevusAuth( serializer: (user) => user.id ?? '', deserializer: (id) => fetchAUserByIdSomehow(id ); @@ -58,7 +58,7 @@ A frequent use case within SPA's is opening OAuth login endpoints in a separate configureServer(Protevus app) async { var handler = auth.authenticate( 'facebook', - AngelAuthOptions(callback: confirmPopupAuthentication())); + ProtevusAuthOptions(callback: confirmPopupAuthentication())); app.get('/auth/facebook', handler); // Use a comma to try multiple strategies!!! diff --git a/packages/auth/example/example.dart b/packages/auth/example/example.dart index 8e3c63e1..dcbf0f57 100644 --- a/packages/auth/example/example.dart +++ b/packages/auth/example/example.dart @@ -5,7 +5,7 @@ import 'package:protevus_framework/http.dart'; void main() async { var app = Protevus(); - var auth = AngelAuth( + var auth = ProtevusAuth( serializer: (user) => user.id ?? '', deserializer: (id) => fetchAUserByIdSomehow(id)); diff --git a/packages/auth/example/example1.dart b/packages/auth/example/example1.dart index 334b3a51..8a43ecb7 100644 --- a/packages/auth/example/example1.dart +++ b/packages/auth/example/example1.dart @@ -64,7 +64,7 @@ void main() async { .findService('users') ?.create({'username': 'jdoe1', 'password': 'password'}); - var auth = AngelAuth( + var auth = ProtevusAuth( serializer: (u) => u.id ?? '', deserializer: (id) async => await app.findService('users')?.read(id) as User); @@ -88,7 +88,8 @@ void main() async { app.post( '/login', - auth.authenticate('local', AngelAuthOptions(callback: (req, res, token) { + auth.authenticate('local', + ProtevusAuthOptions(callback: (req, res, token) { res ..write('Hello!') ..close(); diff --git a/packages/auth/example/example2.dart b/packages/auth/example/example2.dart index e88d6894..5302a6da 100644 --- a/packages/auth/example/example2.dart +++ b/packages/auth/example/example2.dart @@ -7,13 +7,15 @@ import 'package:logging/logging.dart'; final Map sampleUser = {'hello': 'world'}; -final AngelAuth> auth = AngelAuth>( - serializer: (user) async => '1337', deserializer: (id) async => sampleUser); +final ProtevusAuth> auth = + ProtevusAuth>( + serializer: (user) async => '1337', + deserializer: (id) async => sampleUser); //var headers = {'accept': 'application/json'}; -var localOpts = AngelAuthOptions>( +var localOpts = ProtevusAuthOptions>( failureRedirect: '/failure', successRedirect: '/success'); var localOpts2 = - AngelAuthOptions>(canRespondWithJson: false); + ProtevusAuthOptions>(canRespondWithJson: false); Future> verifier(String? username, String? password) async { if (username == 'username' && password == 'password') { diff --git a/packages/auth/lib/src/options.dart b/packages/auth/lib/src/options.dart index 87f50694..4fd4856b 100644 --- a/packages/auth/lib/src/options.dart +++ b/packages/auth/lib/src/options.dart @@ -3,15 +3,15 @@ import 'dart:async'; import 'package:protevus_framework/protevus_framework.dart'; import 'auth_token.dart'; -typedef AngelAuthCallback = FutureOr Function( +typedef ProtevusAuthCallback = FutureOr Function( RequestContext req, ResponseContext res, String token); -typedef AngelAuthTokenCallback = FutureOr Function( +typedef ProtevusAuthTokenCallback = FutureOr Function( RequestContext req, ResponseContext res, AuthToken token, User user); -class AngelAuthOptions { - AngelAuthCallback? callback; - AngelAuthTokenCallback? tokenCallback; +class ProtevusAuthOptions { + ProtevusAuthCallback? callback; + ProtevusAuthTokenCallback? tokenCallback; String? successRedirect; String? failureRedirect; @@ -21,7 +21,7 @@ class AngelAuthOptions { /// Works well with `Basic` authentication. bool canRespondWithJson; - AngelAuthOptions( + ProtevusAuthOptions( {this.callback, this.tokenCallback, this.canRespondWithJson = true, diff --git a/packages/auth/lib/src/plugin.dart b/packages/auth/lib/src/plugin.dart index 38afe928..32f9e2d1 100644 --- a/packages/auth/lib/src/plugin.dart +++ b/packages/auth/lib/src/plugin.dart @@ -10,8 +10,8 @@ import 'options.dart'; import 'strategy.dart'; /// Handles authentication within an Protevus application. -class AngelAuth { - final _log = Logger('AngelAuth'); +class ProtevusAuth { + final _log = Logger('ProtevusAuth'); late Hmac _hs256; late int _jwtLifeSpan; @@ -78,7 +78,7 @@ class AngelAuth { } /// `jwtLifeSpan` - should be in *milliseconds*. - AngelAuth( + ProtevusAuth( {String? jwtKey, required this.serializer, required this.deserializer, @@ -101,11 +101,11 @@ class AngelAuth { /* if (serializer == null) { throw StateError( - 'An `AngelAuth` plug-in was called without its `serializer` being set. All authentication will fail.'); + 'An `ProtevusAuth` plug-in was called without its `serializer` being set. All authentication will fail.'); } if (deserializer == null) { throw StateError( - 'An `AngelAuth` plug-in was called without its `deserializer` being set. All authentication will fail.'); + 'An `ProtevusAuth` plug-in was called without its `deserializer` being set. All authentication will fail.'); } if (app.container == null) { @@ -117,8 +117,8 @@ class AngelAuth { var appContainer = app.container; appContainer.registerSingleton(this); - if (runtimeType != AngelAuth) { - appContainer.registerSingleton(this, as: AngelAuth); + if (runtimeType != ProtevusAuth) { + appContainer.registerSingleton(this, as: ProtevusAuth); } if (!appContainer.has<_AuthResult>()) { @@ -128,7 +128,7 @@ class AngelAuth { var res = container.make(); //if (req == null || res == null) { // _log.warning('RequestContext or responseContext is null'); - // throw AngelHttpException.forbidden(); + // throw ProtevusHttpException.forbidden(); //} var result = await _decodeJwt(req, res); @@ -187,7 +187,7 @@ class AngelAuth { /// `makeAsync`, or Protevus's injections directly: /// /// ```dart - /// var auth = AngelAuth(...); + /// var auth = ProtevusAuth(...); /// await app.configure(auth.configureServer); /// /// app.get('/hmm', (User user) async { @@ -355,9 +355,9 @@ class AngelAuth { /// or a `401 Not Authenticated` is thrown, if it is the last one. /// /// Any other result is considered an authenticated user, and terminates the loop. - RequestHandler authenticate(type, [AngelAuthOptions? opt]) { + RequestHandler authenticate(type, [ProtevusAuthOptions? opt]) { return (RequestContext req, ResponseContext res) async { - var authOption = opt ?? AngelAuthOptions(); + var authOption = opt ?? ProtevusAuthOptions(); var names = []; @@ -485,7 +485,7 @@ class AngelAuth { } /// Log an authenticated user out. - RequestHandler logout([AngelAuthOptions? options]) { + RequestHandler logout([ProtevusAuthOptions? options]) { return (RequestContext req, ResponseContext res) async { if (req.container?.has() == true) { var user = req.container?.make(); diff --git a/packages/auth/lib/src/popup_page.dart b/packages/auth/lib/src/popup_page.dart index bfed7c06..a2da77b8 100644 --- a/packages/auth/lib/src/popup_page.dart +++ b/packages/auth/lib/src/popup_page.dart @@ -4,7 +4,7 @@ import 'package:http_parser/http_parser.dart'; import 'options.dart'; /// Displays a default callback page to confirm authentication via popups. -AngelAuthCallback confirmPopupAuthentication({String eventName = 'token'}) { +ProtevusAuthCallback confirmPopupAuthentication({String eventName = 'token'}) { return (req, ResponseContext res, String jwt) { var evt = json.encode(eventName); var detail = json.encode({'detail': jwt}); diff --git a/packages/auth/lib/src/strategies/local.dart b/packages/auth/lib/src/strategies/local.dart index c1f7a596..b8ad7fb8 100644 --- a/packages/auth/lib/src/strategies/local.dart +++ b/packages/auth/lib/src/strategies/local.dart @@ -36,8 +36,8 @@ class LocalAuthStrategy extends AuthStrategy { @override Future authenticate(RequestContext req, ResponseContext res, - [AngelAuthOptions? options]) async { - var localOptions = options ?? AngelAuthOptions(); + [ProtevusAuthOptions? options]) async { + var localOptions = options ?? ProtevusAuthOptions(); User? verificationResult; if (allowBasic) { @@ -129,7 +129,7 @@ class LocalAuthStrategy extends AuthStrategy { return verificationResult; } else { _log.info('Not authenticated'); - throw AngelHttpException.notAuthenticated(); + throw ProtevusHttpException.notAuthenticated(); } */ } diff --git a/packages/auth/lib/src/strategy.dart b/packages/auth/lib/src/strategy.dart index d011fd33..24561dad 100644 --- a/packages/auth/lib/src/strategy.dart +++ b/packages/auth/lib/src/strategy.dart @@ -6,5 +6,5 @@ import 'options.dart'; abstract class AuthStrategy { /// Authenticates or rejects an incoming user. FutureOr authenticate(RequestContext req, ResponseContext res, - [AngelAuthOptions? options]); + [ProtevusAuthOptions? options]); } diff --git a/packages/auth/test/callback_test.dart b/packages/auth/test/callback_test.dart index f6dda007..50d164fe 100644 --- a/packages/auth/test/callback_test.dart +++ b/packages/auth/test/callback_test.dart @@ -37,7 +37,7 @@ class User extends Model { void main() { late Protevus app; late ProtevusHttp angelHttp; - AngelAuth auth; + ProtevusAuth auth; http.Client? client; HttpServer server; String? url; @@ -73,7 +73,7 @@ void main() { .findService('users') ?.create({'username': 'jdoe1', 'password': 'password'}); - auth = AngelAuth( + auth = ProtevusAuth( serializer: (u) => u.id ?? '', deserializer: (id) async => await app.findService('users')?.read(id) as User); @@ -98,7 +98,7 @@ void main() { app.post( '/login', auth.authenticate('local', - AngelAuthOptions(callback: (req, res, token) { + ProtevusAuthOptions(callback: (req, res, token) { res ..write('Hello!') ..close(); diff --git a/packages/auth/test/local_test.dart b/packages/auth/test/local_test.dart index 4604091d..3a27091c 100644 --- a/packages/auth/test/local_test.dart +++ b/packages/auth/test/local_test.dart @@ -8,13 +8,15 @@ import 'package:http/http.dart' as http; import 'package:logging/logging.dart'; import 'package:test/test.dart'; -final AngelAuth> auth = AngelAuth>( - serializer: (user) async => '1337', deserializer: (id) async => sampleUser); +final ProtevusAuth> auth = + ProtevusAuth>( + serializer: (user) async => '1337', + deserializer: (id) async => sampleUser); //var headers = {'accept': 'application/json'}; -var localOpts = AngelAuthOptions>( +var localOpts = ProtevusAuthOptions>( failureRedirect: '/failure', successRedirect: '/success'); var localOpts2 = - AngelAuthOptions>(canRespondWithJson: false); + ProtevusAuthOptions>(canRespondWithJson: false); Map sampleUser = {'hello': 'world'}; diff --git a/packages/auth/test/protect_cookie_test.dart b/packages/auth/test/protect_cookie_test.dart index 49c08b18..df85ce1b 100644 --- a/packages/auth/test/protect_cookie_test.dart +++ b/packages/auth/test/protect_cookie_test.dart @@ -7,7 +7,7 @@ const Duration threeDays = Duration(days: 3); void main() { late Cookie defaultCookie; - var auth = AngelAuth( + var auth = ProtevusAuth( secureCookies: true, cookieDomain: 'SECURE', jwtLifeSpan: threeDays.inMilliseconds, diff --git a/packages/auth_oauth2/CHANGELOG.md b/packages/auth_oauth2/CHANGELOG.md index 7973db99..d676a9ef 100644 --- a/packages/auth_oauth2/CHANGELOG.md +++ b/packages/auth_oauth2/CHANGELOG.md @@ -71,4 +71,4 @@ ## 1.0.2 -Added `getParameters` to `AngelOAuth2Options`. +Added `getParameters` to `ProtevusOAuth2Options`. diff --git a/packages/auth_oauth2/README.md b/packages/auth_oauth2/README.md index 151e9623..ad153616 100644 --- a/packages/auth_oauth2/README.md +++ b/packages/auth_oauth2/README.md @@ -71,7 +71,7 @@ configureServer(Protevus app) { } ``` -Lastly, connect it to an `AngelAuth` instance, and wire it up to an `Protevus` server. Set up two routes: +Lastly, connect it to an `ProtevusAuth` instance, and wire it up to an `Protevus` server. Set up two routes: 1. Redirect users to the external provider 2. Acts as a callback and handles an access code @@ -81,7 +81,7 @@ In the case of the callback route, you may want to display an HTML page that clo ```dart configureServer(Protevus app) async { // ... - var auth = AngelAuth(); + var auth = ProtevusAuth(); auth.strategies['github'] = oauth2Strategy; // Redirect @@ -90,7 +90,7 @@ configureServer(Protevus app) async { // Callback app.get('/auth/github/callback', auth.authenticate( 'github', - AngelAuthOptions(callback: confirmPopupAuthentication()) + ProtevusAuthOptions(callback: confirmPopupAuthentication()) )); // Connect the plug-in!!! diff --git a/packages/auth_oauth2/example/main.dart b/packages/auth_oauth2/example/main.dart index 75a999ee..325dc535 100644 --- a/packages/auth_oauth2/example/main.dart +++ b/packages/auth_oauth2/example/main.dart @@ -47,7 +47,7 @@ void main() async { var mappedUserService = userService.map(User.parse, User.serialize); // Set up the authenticator plugin. - var auth = AngelAuth( + var auth = ProtevusAuth( serializer: (user) async => user.id ?? '', deserializer: (id) => mappedUserService.read(id), jwtKey: 'oauth2 example secret', @@ -94,7 +94,7 @@ void main() async { app.get( '/auth/github/callback', auth.authenticate('github', - AngelAuthOptions(callback: (req, res, jwt) async { + ProtevusAuthOptions(callback: (req, res, jwt) async { // In real-life, you might include a pop-up callback script. // // Use `confirmPopupAuthentication`, which is bundled with diff --git a/packages/auth_oauth2/lib/protevus_auth_oauth2.dart b/packages/auth_oauth2/lib/protevus_auth_oauth2.dart index 16f3b879..744cb0e0 100644 --- a/packages/auth_oauth2/lib/protevus_auth_oauth2.dart +++ b/packages/auth_oauth2/lib/protevus_auth_oauth2.dart @@ -47,7 +47,7 @@ class OAuth2Strategy implements AuthStrategy { @override FutureOr authenticate(RequestContext req, ResponseContext res, - [AngelAuthOptions? options]) async { + [ProtevusAuthOptions? options]) async { if (options != null) { var result = await authenticateCallback(req, res, options); if (result is User) { @@ -71,7 +71,7 @@ class OAuth2Strategy implements AuthStrategy { /// The endpoint that is invoked by the third-party after successful authentication. Future authenticateCallback(RequestContext req, ResponseContext res, - [AngelAuthOptions? options]) async { + [ProtevusAuthOptions? options]) async { var grant = _createGrant(); grant.getAuthorizationUrl(this.options.redirectUri, scopes: this.options.scopes); diff --git a/packages/auth_twitter/example/example.dart b/packages/auth_twitter/example/example.dart index 271da4a1..cf0bf5c9 100644 --- a/packages/auth_twitter/example/example.dart +++ b/packages/auth_twitter/example/example.dart @@ -17,7 +17,7 @@ class _User { void main() async { var app = Protevus(); var http = ProtevusHttp(app); - var auth = AngelAuth<_User>( + var auth = ProtevusAuth<_User>( jwtKey: 'AUTH_TWITTER_SECRET', allowCookie: false, serializer: (user) async => user.handle, @@ -59,7 +59,7 @@ void main() async { '/auth/twitter/callback', auth.authenticate( 'twitter', - AngelAuthOptions( + ProtevusAuthOptions( callback: (req, res, jwt) { return res.redirect('/home?token=$jwt'); }, diff --git a/packages/auth_twitter/lib/protevus_auth_twitter.dart b/packages/auth_twitter/lib/protevus_auth_twitter.dart index aa01bcff..a7b7cbda 100644 --- a/packages/auth_twitter/lib/protevus_auth_twitter.dart +++ b/packages/auth_twitter/lib/protevus_auth_twitter.dart @@ -119,7 +119,7 @@ class TwitterStrategy extends AuthStrategy { @override Future authenticate(RequestContext req, ResponseContext res, - [AngelAuthOptions? options]) async { + [ProtevusAuthOptions? options]) async { try { if (options != null) { var result = await authenticateCallback(req, res, options); @@ -145,8 +145,8 @@ class TwitterStrategy extends AuthStrategy { } } - Future authenticateCallback( - RequestContext req, ResponseContext res, AngelAuthOptions options) async { + Future authenticateCallback(RequestContext req, ResponseContext res, + ProtevusAuthOptions options) async { try { if (req.queryParameters.containsKey('denied')) { throw TwitterAuthorizationException( diff --git a/packages/cache/README.md b/packages/cache/README.md index 3bdefa6d..58c93ed0 100644 --- a/packages/cache/README.md +++ b/packages/cache/README.md @@ -84,7 +84,7 @@ Some servers expect a reverse proxy or caching layer to support `PURGE` requests Future configureServer(Protevus app) async { app.addRoute('PURGE', '*', (req, res) { if (req.ip != '127.0.0.1') - throw AngelHttpException.forbidden(); + throw ProtevusHttpException.forbidden(); return cache.purge(req.uri.path); }); } diff --git a/packages/client/CHANGELOG.md b/packages/client/CHANGELOG.md index 6243bc10..cf63405e 100644 --- a/packages/client/CHANGELOG.md +++ b/packages/client/CHANGELOG.md @@ -72,7 +72,7 @@ ## 2.0.1 -* Change `BaseAngelClient` constructor to accept `dynamic` instead of `String` for `baseUrl. +* Change `BaseProtevusClient` constructor to accept `dynamic` instead of `String` for `baseUrl. ## 2.0.0 diff --git a/packages/client/README.md b/packages/client/README.md index bdfab3b9..1c7d0293 100644 --- a/packages/client/README.md +++ b/packages/client/README.md @@ -65,7 +65,7 @@ print(auth.data); // User object Revive an existing jwt: ```dart -Future reviveJwt(String jwt) { +Future reviveJwt(String jwt) { return app.authenticate(credentials: {'token': jwt}); } ``` diff --git a/packages/client/example/example1.dart b/packages/client/example/example1.dart index 954423e3..63d9512b 100644 --- a/packages/client/example/example1.dart +++ b/packages/client/example/example1.dart @@ -6,11 +6,11 @@ import 'package:logging/logging.dart'; void main() async { const Map user = {'username': 'foo', 'password': 'bar'}; var localOpts = - AngelAuthOptions>(canRespondWithJson: true); + ProtevusAuthOptions>(canRespondWithJson: true); Protevus app = Protevus(); ProtevusHttp http = ProtevusHttp(app, useZone: false); - var auth = AngelAuth( + var auth = ProtevusAuth( serializer: (_) async => 'baz', deserializer: (_) async => user); auth.strategies['local'] = LocalAuthStrategy((username, password) async { diff --git a/packages/client/lib/base_protevus_client.dart b/packages/client/lib/base_protevus_client.dart index 100da4ff..b776e807 100644 --- a/packages/client/lib/base_protevus_client.dart +++ b/packages/client/lib/base_protevus_client.dart @@ -42,7 +42,7 @@ ProtevusHttpException failure(Response response, } abstract class BaseProtevusClient extends Protevus { - final _log = Logger('BaseAngelClient'); + final _log = Logger('BaseProtevusClient'); final StreamController _onAuthenticated = StreamController(); final List _services = []; diff --git a/packages/client/test/all_test.dart b/packages/client/test/all_test.dart index 602d6315..e3bfe6f5 100644 --- a/packages/client/test/all_test.dart +++ b/packages/client/test/all_test.dart @@ -3,7 +3,7 @@ import 'package:test/test.dart'; import 'common.dart'; void main() { - var app = MockAngel(); + var app = MockProtevus(); var todoService = app.service('api/todos'); test('sets method,body,headers,path', () async { diff --git a/packages/client/test/auth_test.dart b/packages/client/test/auth_test.dart index 6f984def..4f2928e8 100644 --- a/packages/client/test/auth_test.dart +++ b/packages/client/test/auth_test.dart @@ -6,7 +6,8 @@ import 'package:logging/logging.dart'; import 'package:test/test.dart'; const Map user = {'username': 'foo', 'password': 'bar'}; -var localOpts = AngelAuthOptions>(canRespondWithJson: true); +var localOpts = + ProtevusAuthOptions>(canRespondWithJson: true); void main() { late Protevus app; @@ -16,7 +17,7 @@ void main() { setUp(() async { app = Protevus(); http = ProtevusHttp(app, useZone: false); - var auth = AngelAuth( + var auth = ProtevusAuth( serializer: (_) async => 'baz', deserializer: (_) async => user); auth.strategies['local'] = LocalAuthStrategy( diff --git a/packages/client/test/common.dart b/packages/client/test/common.dart index 7fe2b7a1..91c0e5a2 100644 --- a/packages/client/test/common.dart +++ b/packages/client/test/common.dart @@ -8,13 +8,13 @@ import 'package:http/src/streamed_response.dart' as http; Future read(Stream> stream) => stream.transform(utf8.decoder).join(); -class MockAngel extends BaseProtevusClient { +class MockProtevus extends BaseProtevusClient { final SpecClient specClient = SpecClient(); @override get client => specClient; - MockAngel() : super(SpecClient(), 'http://localhost:3000'); + MockProtevus() : super(SpecClient(), 'http://localhost:3000'); @override Stream authenticateViaPopup(String url, diff --git a/packages/core/container/container/README.md b/packages/core/container/container/README.md index fcf9c7f6..12ff218a 100644 --- a/packages/core/container/container/README.md +++ b/packages/core/container/container/README.md @@ -38,7 +38,7 @@ A better IoC container for Protevus, ultimately allowing Protevus to be used wit app.container.registerSingleton(SalesController()); await app.mountController(); - var http = AngelHttp(app); + var http = ProtevusHttp(app); var server = await http.startServer('localhost', 3000); print("Protevus server listening at ${http.uri}"); } diff --git a/packages/core/exceptions/CHANGELOG.md b/packages/core/exceptions/CHANGELOG.md index 8749d86b..e51d90b5 100644 --- a/packages/core/exceptions/CHANGELOG.md +++ b/packages/core/exceptions/CHANGELOG.md @@ -29,7 +29,7 @@ ## 6.0.0 * Require Dart >= 2.16 -* [**Breaking**] `error` for `AngelHttpException` is no longer mandatory +* [**Breaking**] `error` for `ProtevusHttpException` is no longer mandatory ## 5.0.0 diff --git a/packages/core/framework/CHANGELOG.md b/packages/core/framework/CHANGELOG.md index fd5ec537..7be2da19 100644 --- a/packages/core/framework/CHANGELOG.md +++ b/packages/core/framework/CHANGELOG.md @@ -20,8 +20,8 @@ ## 8.2.0 -* Add `addResponseHeader` to `AngelHttp` to add headers to HTTP default response -* Add `removeResponseHeader` to `AngelHttp` to remove headers from HTTP default response +* Add `addResponseHeader` to `ProtevusHttp` to add headers to HTTP default response +* Add `removeResponseHeader` to `ProtevusHttp` to remove headers from HTTP default response ## 8.1.1 @@ -138,7 +138,7 @@ ## 2.1.1 -* `AngelHttp.uri` now returns an empty `Uri` if the server is not listening. +* `ProtevusHttp.uri` now returns an empty `Uri` if the server is not listening. ## 2.1.0 @@ -150,7 +150,7 @@ therefore been bumped to `2.1.0`. ## 2.0.5-beta * Make `@Expose()` in `Controller` optional. -* Add `allowHttp1` to `AngelHttp2` constructors. +* Add `allowHttp1` to `ProtevusHttp2` constructors. * Add `deserializeBody` and `decodeBody` to `RequestContext`. * Add `HostnameRouter`, which allows for routing based on hostname. * Default to using `ThrowingReflector`, instead of `EmptyReflector`. This will give a more descriptive @@ -189,7 +189,7 @@ See more: `, instead of just `FutureOr`. +* ProtevusConfigurer is now `FutureOr`, instead of just `FutureOr`. * Use a `Container.has` check in `Driver.sendResponse`. * Remove unnecessary `new` and `const`. @@ -199,7 +199,7 @@ handlers to run, even after the response was closed. ## 2.0.0-rc.10 -* Fix an error that prevented `AngelHttp2.custom` from working properly. +* Fix an error that prevented `ProtevusHttp2.custom` from working properly. * Add `startSharedHttp2`. ## 2.0.0-rc.9 @@ -246,7 +246,7 @@ the outputs of `before` events. ## 2.0.0-rc.0 * Log a warning when no `reflector` is provided. -* Add `AngelEnvironment` class. +* Add `ProtevusEnvironment` class. * Add `Protevus.environment`. * Deprecated `app.isProduction` in favor of `app.environment.isProduction`. * Allow setting of `bodyAsObject`, `bodyAsMap`, or `bodyAsList` **exactly once**. diff --git a/packages/core/framework/example/http2/body_parsing.dart b/packages/core/framework/example/http2/body_parsing.dart index 8af74261..3b96af83 100644 --- a/packages/core/framework/example/http2/body_parsing.dart +++ b/packages/core/framework/example/http2/body_parsing.dart @@ -38,7 +38,7 @@ void main() async { var http1 = ProtevusHttp(app); var http2 = ProtevusHttp2(app, ctx); - // HTTP/1.x requests will fallback to `AngelHttp` + // HTTP/1.x requests will fallback to `ProtevusHttp` http2.onHttp1.listen(http1.handleRequest); var server = await http2.startServer('127.0.0.1', 3000); diff --git a/packages/core/framework/example/http2/main.dart b/packages/core/framework/example/http2/main.dart index a059580f..074f8040 100644 --- a/packages/core/framework/example/http2/main.dart +++ b/packages/core/framework/example/http2/main.dart @@ -35,7 +35,7 @@ void main() async { var http1 = ProtevusHttp(app); var http2 = ProtevusHttp2(app, ctx); - // HTTP/1.x requests will fallback to `AngelHttp` + // HTTP/1.x requests will fallback to `ProtevusHttp` http2.onHttp1.listen(http1.handleRequest); await http2.startServer('127.0.0.1', 3000); diff --git a/packages/core/framework/example/http2/server_push.dart b/packages/core/framework/example/http2/server_push.dart index b72c4638..6a845292 100644 --- a/packages/core/framework/example/http2/server_push.dart +++ b/packages/core/framework/example/http2/server_push.dart @@ -54,7 +54,7 @@ void main() async { var http1 = ProtevusHttp(app); var http2 = ProtevusHttp2(app, ctx); - // HTTP/1.x requests will fallback to `AngelHttp` + // HTTP/1.x requests will fallback to `ProtevusHttp` http2.onHttp1.listen(http1.handleRequest); var server = await http2.startServer('127.0.0.1', 3000); diff --git a/packages/core/framework/lib/src/core/driver.dart b/packages/core/framework/lib/src/core/driver.dart index 4d79b2e2..722006de 100644 --- a/packages/core/framework/lib/src/core/driver.dart +++ b/packages/core/framework/lib/src/core/driver.dart @@ -10,7 +10,7 @@ import 'core.dart'; /// Base driver class for Protevus implementations. /// -/// Powers both AngelHttp and AngelHttp2. +/// Powers both ProtevusHttp and ProtevusHttp2. abstract class Driver< Request, Response, diff --git a/packages/core/framework/lib/src/core/env.dart b/packages/core/framework/lib/src/core/env.dart index 8e8097ab..fcead62d 100644 --- a/packages/core/framework/lib/src/core/env.dart +++ b/packages/core/framework/lib/src/core/env.dart @@ -1,6 +1,6 @@ import 'dart:io'; -/// A constant instance of [AngelEnv]. +/// A constant instance of [ProtevusEnv]. const ProtevusEnvironment angelEnv = ProtevusEnvironment(); /// Queries the environment's `ANGEL_ENV` value. diff --git a/packages/core/framework/lib/src/core/map_service.dart b/packages/core/framework/lib/src/core/map_service.dart index ac69d8e6..c60de3eb 100644 --- a/packages/core/framework/lib/src/core/map_service.dart +++ b/packages/core/framework/lib/src/core/map_service.dart @@ -96,7 +96,7 @@ class MapService extends Service> { Future> modify(String? id, Map data, [Map? params]) { //if (data is! Map) { - // throw AngelHttpException.badRequest( + // throw ProtevusHttpException.badRequest( // message: // 'MapService does not support `modify` with ${data.runtimeType}.'); //} @@ -119,7 +119,7 @@ class MapService extends Service> { Future> update(String? id, Map data, [Map? params]) { //if (data is! Map) { - // throw AngelHttpException.badRequest( + // throw ProtevusHttpException.badRequest( // message: // 'MapService does not support `update` with ${data.runtimeType}.'); //} diff --git a/packages/core/framework/lib/src/core/service.dart b/packages/core/framework/lib/src/core/service.dart index ec47f844..bbbefc4c 100644 --- a/packages/core/framework/lib/src/core/service.dart +++ b/packages/core/framework/lib/src/core/service.dart @@ -111,7 +111,7 @@ class Service extends Routable { /// Retrieves the first object from the result of calling [index] with the given [params]. /// - /// If the result of [index] is `null`, OR an empty [Iterable], a 404 `AngelHttpException` will be thrown. + /// If the result of [index] is `null`, OR an empty [Iterable], a 404 `ProtevusHttpException` will be thrown. /// /// If the result is both non-null and NOT an [Iterable], it will be returned as-is. /// diff --git a/packages/core/framework/lib/src/http2/angel_http2.dart b/packages/core/framework/lib/src/http2/angel_http2.dart index 2041a8be..4492f9f2 100644 --- a/packages/core/framework/lib/src/http2/angel_http2.dart +++ b/packages/core/framework/lib/src/http2/angel_http2.dart @@ -206,7 +206,7 @@ class _ProtevusHttp2ServerSocket extends Stream } else { socket.destroy(); throw Exception( - 'AngelHttp2 does not support ${socket.selectedProtocol} as an ALPN protocol.'); + 'ProtevusHttp2 does not support ${socket.selectedProtocol} as an ALPN protocol.'); } }, onDone: _ctrl.close, diff --git a/packages/core/framework/test/find_one_test.dart b/packages/core/framework/test/find_one_test.dart index 865db621..8ee8d0ff 100644 --- a/packages/core/framework/test/find_one_test.dart +++ b/packages/core/framework/test/find_one_test.dart @@ -3,19 +3,19 @@ import 'package:test/test.dart'; import 'common.dart'; void main() { - var throwsAnAngelHttpException = + var throwsAnProtevusHttpException = throwsA(const IsInstanceOf()); /* test('throw 404 on null', () { var service = AnonymousService(index: ([p]) => null); - expect(() => service.findOne(), throwsAnAngelHttpException); + expect(() => service.findOne(), throwsAnProtevusHttpException); }); */ test('throw 404 on empty iterable', () { var service = AnonymousService(index: ([p]) => []); - expect(() => service.findOne(), throwsAnAngelHttpException); + expect(() => service.findOne(), throwsAnProtevusHttpException); }); test('return first element of iterable', () async { diff --git a/packages/core/framework/test/server_test.dart b/packages/core/framework/test/server_test.dart index bdf41d4a..163a18f0 100644 --- a/packages/core/framework/test/server_test.dart +++ b/packages/core/framework/test/server_test.dart @@ -154,7 +154,7 @@ void main() { }); }); - group('handleAngelHttpException', () { + group('handleProtevusHttpException', () { late Protevus app; late ProtevusHttp http; diff --git a/packages/core/mocking/test/all_test.dart b/packages/core/mocking/test/all_test.dart index e2279c41..b9b50e9b 100644 --- a/packages/core/mocking/test/all_test.dart +++ b/packages/core/mocking/test/all_test.dart @@ -20,7 +20,7 @@ void main() { return res.serialize(req.ip == InternetAddress.loopbackIPv4.address); }); - var http = AngelHttp(app); + var http = ProtevusHttp(app); test('receive a response', () async { var rq = MockHttpRequest('GET', uri.resolve('/foo')); diff --git a/packages/hot/README.md b/packages/hot/README.md index 90afc2f8..13daae05 100644 --- a/packages/hot/README.md +++ b/packages/hot/README.md @@ -58,7 +58,7 @@ Future createServer() async { app.get('/', (req, res) => {'hello': 'hot world!'}); app.get('/foo', (req, res) => Foo(bar: 'baz')); - app.fallback((req, res) => throw AngelHttpException.notFound()); + app.fallback((req, res) => throw ProtevusHttpException.notFound()); app.encoders.addAll({ 'gzip': gzip.encoder, diff --git a/packages/jael/angel_jael/README.md b/packages/jael/angel_jael/README.md index 5ce4c848..182824f6 100644 --- a/packages/jael/angel_jael/README.md +++ b/packages/jael/angel_jael/README.md @@ -25,7 +25,7 @@ import 'package:protevus_framework/protevus_framework.dart'; import 'package:protevus_jael/protevus_jael.dart'; import 'package:file/file.dart'; -AngelConfigurer myPlugin(FileSystem fileSystem) { +ProtevusConfigurer myPlugin(FileSystem fileSystem) { return (Protevus app) async { // Connect Jael to your server... await app.configure( @@ -62,7 +62,7 @@ void main() async { // Render the contents of views/index.jael app.get('/', (res) => res.render('index', {'title': 'ESKETTIT'})); - app.use(() => throw AngelHttpException.notFound()); + app.use(() => throw ProtevusHttpException.notFound()); app.logger = Logger('protevus') ..onRecord.listen((rec) { diff --git a/packages/jinja/README.md b/packages/jinja/README.md index 90e413ce..c412b0cf 100644 --- a/packages/jinja/README.md +++ b/packages/jinja/README.md @@ -18,7 +18,7 @@ import 'package:path/path.dart' as p; void main() async { var app = Protevus(); - var http = AngelHttp(app); + var http = ProtevusHttp(app); var viewsDir = p.join( p.dirname( p.fromUri(Platform.script), diff --git a/packages/oauth2/CHANGELOG.md b/packages/oauth2/CHANGELOG.md index 2a0b95b7..c40ac5a0 100644 --- a/packages/oauth2/CHANGELOG.md +++ b/packages/oauth2/CHANGELOG.md @@ -25,7 +25,7 @@ ## 6.0.1 -* Fixed AngelHttpException error +* Fixed ProtevusHttpException error * [Breaking] Renamed `error` to `authError` for `AuthorizationException` ## 6.0.0 diff --git a/packages/orm/README.md b/packages/orm/README.md index f13fff90..94e75bad 100644 --- a/packages/orm/README.md +++ b/packages/orm/README.md @@ -80,7 +80,7 @@ simply just not extend `Model`: ```dart @Serializable -abstract class _ThisIsNotAnAngelModel { +abstract class _ThisIsNotAnProtevusModel { @primaryKey String get username; } @@ -97,7 +97,7 @@ import 'car.dart'; import 'car.orm.g.dart'; /// Returns an Protevus plug-in that connects to a database, and sets up a controller connected to it... -AngelConfigurer connectToCarsTable(QueryExecutor executor) { +ProtevusConfigurer connectToCarsTable(QueryExecutor executor) { return (Protevus app) async { // Register the connection with Protevus's dependency injection system. // diff --git a/packages/paginate/CHANGELOG.md b/packages/paginate/CHANGELOG.md index 4fec76b2..0266b5ff 100644 --- a/packages/paginate/CHANGELOG.md +++ b/packages/paginate/CHANGELOG.md @@ -45,5 +45,5 @@ ## 2.0.0 -* Dart2 + Angel2 update. +* Dart2 + Protevus2 update. \ No newline at end of file diff --git a/packages/production/lib/src/runner.dart b/packages/production/lib/src/runner.dart index e3da1467..5e14070f 100644 --- a/packages/production/lib/src/runner.dart +++ b/packages/production/lib/src/runner.dart @@ -283,7 +283,7 @@ class Runner { await driver.startServer(args.options.hostname, args.options.port); - // Only apply the headers to AngelHttp instance + // Only apply the headers to ProtevusHttp instance if (driver is ProtevusHttp) { driver.addResponseHeader(args.options.responseHeaders); driver.removeResponseHeader(args.options.removeResponseHeaders); diff --git a/packages/security/CHANGELOG.md b/packages/security/CHANGELOG.md index 1648d110..cafc7e43 100644 --- a/packages/security/CHANGELOG.md +++ b/packages/security/CHANGELOG.md @@ -24,7 +24,7 @@ ## 6.0.1 -* Fixed AngelHttpException error +* Fixed ProtevusHttpException error ## 6.0.0 diff --git a/packages/seo/README.md b/packages/seo/README.md index 23f40449..46e58ae6 100644 --- a/packages/seo/README.md +++ b/packages/seo/README.md @@ -32,11 +32,11 @@ import 'package:file/local.dart'; void main() async { var app = Protevus()..lazyParseBodies = true; var fs = const LocalFileSystem(); - var http = AngelHttp(app); + var http = ProtevusHttp(app); app.responseFinalizers.add(inlineAssets(fs.directory('web'))); - app.use(() => throw AngelHttpException.notFound()); + app.use(() => throw ProtevusHttpException.notFound()); var server = await http.startServer('127.0.0.1', 3000); print('Listening at http://${server.address.address}:${server.port}'); @@ -56,7 +56,7 @@ import 'package:file/local.dart'; void main() async { var app = Protevus()..lazyParseBodies = true; var fs = const LocalFileSystem(); - var http = AngelHttp(app); + var http = ProtevusHttp(app); var vDir = inlineAssets( VirtualDirectory( @@ -68,7 +68,7 @@ void main() async { app.use(vDir.handleRequest); - app.use(() => throw AngelHttpException.notFound()); + app.use(() => throw ProtevusHttpException.notFound()); var server = await http.startServer('127.0.0.1', 3000); print('Listening at http://${server.address.address}:${server.port}'); diff --git a/packages/shelf/CHANGELOG.md b/packages/shelf/CHANGELOG.md index d4afc403..eca8a555 100644 --- a/packages/shelf/CHANGELOG.md +++ b/packages/shelf/CHANGELOG.md @@ -17,7 +17,7 @@ ## 6.0.0-beta.2 -* Fixed AngelHttpException error +* Fixed ProtevusHttpException error ## 6.0.0-beta.1 @@ -47,7 +47,7 @@ ## 2.1.0 * `pedantic` lints. -* Add the `AngelShelf` driver class, which allows you to embed Protevus within shelf. +* Add the `ProtevusShelf` driver class, which allows you to embed Protevus within shelf. ## 2.0.0 diff --git a/packages/shelf/README.md b/packages/shelf/README.md index 4d27bd13..0805afd6 100644 --- a/packages/shelf/README.md +++ b/packages/shelf/README.md @@ -13,7 +13,7 @@ Shelf interop with Protevus. This package lets you run `package:shelf` handlers - [Usage](#usage) - [embedShelf](#embedshelf) - [Communicating with Protevus with embedShelf](#communicating-with-protevus-with-embedshelf) - - [AngelShelf](#angelshelf) + - [ProtevusShelf](#angelshelf) ## Usage @@ -31,7 +31,7 @@ import 'api/api.dart'; void main() async { var app = Protevus(); - var http = AngelHttp(app); + var http = ProtevusHttp(app); // Protevus routes on top await app.mountController(); @@ -70,24 +70,24 @@ handleRequest(shelf.Request request) { } ``` -### AngelShelf +### ProtevusShelf -Protevus brought about the generic `Driver` class, which is implemented by `AngelHttp`, `AngelHttp2`, `AngelGopher`, etc., and provides the core infrastructure for request handling in Protevus. `AngelShelf` is an implementation that wraps shelf requests and responses in their Protevus equivalents. Using it is as simple using as using `AngelHttp`, or any other driver: +Protevus brought about the generic `Driver` class, which is implemented by `ProtevusHttp`, `ProtevusHttp2`, `ProtevusGopher`, etc., and provides the core infrastructure for request handling in Protevus. `ProtevusShelf` is an implementation that wraps shelf requests and responses in their Protevus equivalents. Using it is as simple using as using `ProtevusHttp`, or any other driver: ```dart -// Create an AngelShelf driver. +// Create an ProtevusShelf driver. // If we have startup hooks we want to run, we need to call // `startServer`. Otherwise, it can be omitted. // Of course, if you call `startServer`, know that to run // shutdown/cleanup logic, you need to call `close` eventually, // too. -var angelShelf = AngelShelf(app); +var angelShelf = ProtevusShelf(app); await angelShelf.startServer(); await shelf_io.serve(angelShelf.handler, InternetAddress.loopbackIPv4, 8081); ``` -You can also use the `AngelShelf` driver as a shelf middleware - just use +You can also use the `ProtevusShelf` driver as a shelf middleware - just use `angelShelf.middleware` instead of `angelShelf.handler`. When used as a middleware, if the Protevus response context is still open after all handlers run (i.e. no routes were matched), the next shelf handler will be called. diff --git a/packages/static/README.md b/packages/static/README.md index 3df7fae9..4549fb41 100644 --- a/packages/static/README.md +++ b/packages/static/README.md @@ -40,7 +40,7 @@ void main() async { app.fallback(vDir.handleRequest); // Start your server!!! - await AngelHttp(app).startServer(); + await ProtevusHttp(app).startServer(); } ``` diff --git a/packages/sync/README.md b/packages/sync/README.md index 9a815154..1c4e603a 100644 --- a/packages/sync/README.md +++ b/packages/sync/README.md @@ -9,10 +9,10 @@ Easily synchronize and scale WebSockets using [belatuk_pub_sub](', adapter.receivePort.sendPort), ), diff --git a/packages/test/CHANGELOG.md b/packages/test/CHANGELOG.md index 28bf7e87..9069184c 100644 --- a/packages/test/CHANGELOG.md +++ b/packages/test/CHANGELOG.md @@ -102,4 +102,4 @@ ## 1.1.0+1 * Dart 2/strong mode fixes. -* Pass a `useZone` flag to `AngelHttp` through `TestServer`. +* Pass a `useZone` flag to `ProtevusHttp` through `TestServer`. diff --git a/packages/test/README.md b/packages/test/README.md index f2522970..02a12585 100644 --- a/packages/test/README.md +++ b/packages/test/README.md @@ -41,8 +41,8 @@ void test('foo', () async { void test('error', () async { var res = await client.get('/error'); - expect(res, isAngelHttpException()); - expect(res, isAngelHttpException(statusCode: 404, message: ..., errors: [...])) // Optional + expect(res, isProtevusHttpException()); + expect(res, isProtevusHttpException(statusCode: 404, message: ..., errors: [...])) // Optional }); ``` diff --git a/packages/validate/CHANGELOG.md b/packages/validate/CHANGELOG.md index 35dd3074..fb94e438 100644 --- a/packages/validate/CHANGELOG.md +++ b/packages/validate/CHANGELOG.md @@ -93,5 +93,5 @@ ## 1.0.4 * `isNonEmptyString` trims strings. -* `ValidationException` extends `AngelHttpException`. +* `ValidationException` extends `ProtevusHttpException`. * Added `requireField` and `requireFields`. diff --git a/packages/validate/README.md b/packages/validate/README.md index 3645045a..62cee790 100644 --- a/packages/validate/README.md +++ b/packages/validate/README.md @@ -260,7 +260,7 @@ main() { `server.dart` exposes seven helper middleware: -- `validate(validator)`: Validates and filters `req.bodyAsMap`, and throws an `AngelHttpException.BadRequest` if data is invalid. +- `validate(validator)`: Validates and filters `req.bodyAsMap`, and throws an `ProtevusHttpException.BadRequest` if data is invalid. - `validateEvent(validator)`: Sets `e.data` to the result of validation on a service event. - `validateQuery(validator)`: Same as `validate`, but operates on `req.query`. - `autoParseBody(fields)`: Auto-parses numbers in `req.bodyAsMap`. diff --git a/packages/validate/lib/server.dart b/packages/validate/lib/server.dart index 22892a09..f0b8f017 100644 --- a/packages/validate/lib/server.dart +++ b/packages/validate/lib/server.dart @@ -114,7 +114,7 @@ HookedServiceEventListener validateEvent(Validator validator, }; } -/// Asynchronously apply a [validator], running any [AngelMatcher]s. +/// Asynchronously apply a [validator], running any [ProtevusMatcher]s. Future asyncApplyValidator( Validator validator, Map data, Protevus app) async { var result = validator.check(data); @@ -127,8 +127,9 @@ Future asyncApplyValidator( var description = StringDescription("'$key': expected "); for (var rule in validator.rules[key]!) { - if (rule is AngelMatcher) { - var r = await rule.matchesWithAngel(value, key, result.data, {}, app); + if (rule is ProtevusMatcher) { + var r = + await rule.matchesWithProtevus(value, key, result.data, {}, app); if (!r) { errors.add(rule.describe(description).toString().trim()); diff --git a/packages/validate/lib/src/async.dart b/packages/validate/lib/src/async.dart index a0b86e4d..73ead601 100644 --- a/packages/validate/lib/src/async.dart +++ b/packages/validate/lib/src/async.dart @@ -3,60 +3,61 @@ import 'package:protevus_framework/protevus_framework.dart'; import 'package:matcher/matcher.dart'; import 'context_aware.dart'; -/// Returns an [AngelMatcher] that uses an arbitrary function that returns +/// Returns an [ProtevusMatcher] that uses an arbitrary function that returns /// true or false for the actual value. /// /// Analogous to the synchronous [predicate] matcher. -AngelMatcher predicateWithAngel( +ProtevusMatcher predicateWithProtevus( FutureOr Function(String, Object, Protevus) f, [String description = 'satisfies function']) => - _PredicateWithAngel(f, description); + _PredicateWithProtevus(f, description); -/// Returns an [AngelMatcher] that applies an asynchronously-created [Matcher] +/// Returns an [ProtevusMatcher] that applies an asynchronously-created [Matcher] /// to the input. /// /// Use this to match values against configuration, injections, etc. -AngelMatcher matchWithAngel(FutureOr Function(Object, Map, Protevus) f, +ProtevusMatcher matchWithProtevus( + FutureOr Function(Object, Map, Protevus) f, [String description = 'satisfies asynchronously created matcher']) => - _MatchWithAngel(f, description); + _MatchWithProtevus(f, description); -/// Calls [matchWithAngel] without the initial parameter. -AngelMatcher matchWithAngelBinary( +/// Calls [matchWithProtevus] without the initial parameter. +ProtevusMatcher matchWithProtevusBinary( FutureOr Function(Map context, Protevus) f, [String description = 'satisfies asynchronously created matcher']) => - matchWithAngel((_, context, app) => f(context, app)); + matchWithProtevus((_, context, app) => f(context, app)); -/// Calls [matchWithAngel] without the initial two parameters. -AngelMatcher matchWithAngelUnary(FutureOr Function(Protevus) f, +/// Calls [matchWithProtevus] without the initial two parameters. +ProtevusMatcher matchWithProtevusUnary(FutureOr Function(Protevus) f, [String description = 'satisfies asynchronously created matcher']) => - matchWithAngelBinary((_, app) => f(app)); + matchWithProtevusBinary((_, app) => f(app)); -/// Calls [matchWithAngel] without any parameters. -AngelMatcher matchWithAngelNullary(FutureOr Function() f, +/// Calls [matchWithProtevus] without any parameters. +ProtevusMatcher matchWithProtevusNullary(FutureOr Function() f, [String description = 'satisfies asynchronously created matcher']) => - matchWithAngelUnary((_) => f()); + matchWithProtevusUnary((_) => f()); -/// Returns an [AngelMatcher] that represents [x]. +/// Returns an [ProtevusMatcher] that represents [x]. /// -/// If [x] is an [AngelMatcher], then it is returned, unmodified. -AngelMatcher wrapAngelMatcher(x) { - if (x is AngelMatcher) return x; - if (x is ContextAwareMatcher) return _WrappedAngelMatcher(x); - return wrapAngelMatcher(wrapContextAwareMatcher(x)); +/// If [x] is an [ProtevusMatcher], then it is returned, unmodified. +ProtevusMatcher wrapProtevusMatcher(x) { + if (x is ProtevusMatcher) return x; + if (x is ContextAwareMatcher) return _WrappedProtevusMatcher(x); + return wrapProtevusMatcher(wrapContextAwareMatcher(x)); } -/// Returns an [AngelMatcher] that asynchronously resolves a [feature], builds a [matcher], and executes it. -AngelMatcher matchAsync(FutureOr Function(String, Object) matcher, +/// Returns an [ProtevusMatcher] that asynchronously resolves a [feature], builds a [matcher], and executes it. +ProtevusMatcher matchAsync(FutureOr Function(String, Object) matcher, FutureOr Function() feature, [String description = 'satisfies asynchronously created matcher']) { return _MatchAsync(matcher, feature, description); } -/// Returns an [AngelMatcher] that verifies that an item with the given [idField] +/// Returns an [ProtevusMatcher] that verifies that an item with the given [idField] /// exists in the service at [servicePath], without throwing a `404` or returning `null`. -AngelMatcher idExistsInService(String servicePath, +ProtevusMatcher idExistsInService(String servicePath, {String idField = 'id', String? description}) { - return predicateWithAngel( + return predicateWithProtevus( (key, item, app) async { try { var result = await app.findService(servicePath)?.read(item); @@ -74,8 +75,8 @@ AngelMatcher idExistsInService(String servicePath, } /// An asynchronous [Matcher] that runs in the context of an [Protevus] app. -abstract class AngelMatcher extends ContextAwareMatcher { - Future matchesWithAngel( +abstract class ProtevusMatcher extends ContextAwareMatcher { + Future matchesWithProtevus( item, String key, Map context, Map matchState, Protevus app); @override @@ -84,34 +85,34 @@ abstract class AngelMatcher extends ContextAwareMatcher { } } -class _WrappedAngelMatcher extends AngelMatcher { +class _WrappedProtevusMatcher extends ProtevusMatcher { final ContextAwareMatcher matcher; - _WrappedAngelMatcher(this.matcher); + _WrappedProtevusMatcher(this.matcher); @override Description describe(Description description) => matcher.describe(description); @override - Future matchesWithAngel( + Future matchesWithProtevus( item, String key, Map context, Map matchState, Protevus app) async { return matcher.matchesWithContext(item, key, context, matchState); } } -class _MatchWithAngel extends AngelMatcher { +class _MatchWithProtevus extends ProtevusMatcher { final FutureOr Function(Object, Map, Protevus) f; final String description; - _MatchWithAngel(this.f, this.description); + _MatchWithProtevus(this.f, this.description); @override Description describe(Description description) => description.add(this.description); @override - Future matchesWithAngel( + Future matchesWithProtevus( item, String key, Map context, Map matchState, Protevus app) { return Future.sync(() => f(item as Object, context, app)).then((result) { return result.matches(item, matchState); @@ -119,24 +120,24 @@ class _MatchWithAngel extends AngelMatcher { } } -class _PredicateWithAngel extends AngelMatcher { +class _PredicateWithProtevus extends ProtevusMatcher { final FutureOr Function(String, Object, Protevus) predicate; final String description; - _PredicateWithAngel(this.predicate, this.description); + _PredicateWithProtevus(this.predicate, this.description); @override Description describe(Description description) => description.add(this.description); @override - Future matchesWithAngel( + Future matchesWithProtevus( item, String key, Map context, Map matchState, Protevus app) { return Future.sync(() => predicate(key, item as Object, app)); } } -class _MatchAsync extends AngelMatcher { +class _MatchAsync extends ProtevusMatcher { final FutureOr Function(String, Object) matcher; final FutureOr Function() feature; final String description; @@ -148,11 +149,11 @@ class _MatchAsync extends AngelMatcher { description.add(this.description); @override - Future matchesWithAngel( + Future matchesWithProtevus( item, String key, Map context, Map matchState, Protevus app) async { var f = await feature(); var m = await matcher(key, f as Object); - var c = wrapAngelMatcher(m); - return await c.matchesWithAngel(item, key, context, matchState, app); + var c = wrapProtevusMatcher(m); + return await c.matchesWithProtevus(item, key, context, matchState, app); } } diff --git a/packages/websocket/CHANGELOG.md b/packages/websocket/CHANGELOG.md index 4aaf1f4b..d9b495d6 100644 --- a/packages/websocket/CHANGELOG.md +++ b/packages/websocket/CHANGELOG.md @@ -39,7 +39,7 @@ ## 4.1.1 * Fixed issue with type casting -* Changed `app` parameter of `AngelWebSocket` to non-nullable +* Changed `app` parameter of `ProtevusWebSocket` to non-nullable ## 4.1.0 @@ -124,7 +124,7 @@ * Dart 2 updates. * Added `handleClient`, which is nice for external implementations -that plug into `AngelWebSocket`. +that plug into `ProtevusWebSocket`. ## 1.1.1 diff --git a/packages/websocket/README.md b/packages/websocket/README.md index 031bbf7b..9c882ec5 100644 --- a/packages/websocket/README.md +++ b/packages/websocket/README.md @@ -5,7 +5,7 @@ [![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM) [![License](https://img.shields.io/github/license/dart-backend/protevus)](https://github.com/dart-backend/protevus/tree/master/packages/websocket/LICENSE) -WebSocket plugin for Protevus framework. This plugin broadcasts events from hooked services via WebSockets. In addition, it adds itself to the app's IoC container as `AngelWebSocket`, so that it can be used in controllers as well. +WebSocket plugin for Protevus framework. This plugin broadcasts events from hooked services via WebSockets. In addition, it adds itself to the app's IoC container as `ProtevusWebSocket`, so that it can be used in controllers as well. WebSocket contexts are add to `req.properties` as `'socket'`. @@ -20,7 +20,7 @@ import "package:protevus_websocket/server.dart"; void main() async { var app = Protevus(); - var ws = AngelWebSocket(); + var ws = ProtevusWebSocket(); // This is a plug-in. It hooks all your services, // to automatically broadcast events. @@ -56,7 +56,7 @@ import "package:protevus_websocket/server.dart"; @Expose("/") class MyController extends WebSocketController { // A reference to the WebSocket plug-in is required. - MyController(AngelWebSocket ws):super(ws); + MyController(ProtevusWebSocket ws):super(ws); @override void onConnect(WebSocketContext socket) { diff --git a/packages/websocket/lib/server.dart b/packages/websocket/lib/server.dart index 7a3b8d55..96400560 100644 --- a/packages/websocket/lib/server.dart +++ b/packages/websocket/lib/server.dart @@ -274,7 +274,7 @@ class ProtevusWebSocket { action.params['query'] is Map && action.params['query']['jwt'] is String) { try { - var auth = socket.request.container!.make(); + var auth = socket.request.container!.make(); var jwt = action.params['query']['jwt'] as String; AuthToken token; diff --git a/packages/websocket/test/auth_test.dart b/packages/websocket/test/auth_test.dart index 8a28f1b5..8a7ee3ec 100644 --- a/packages/websocket/test/auth_test.dart +++ b/packages/websocket/test/auth_test.dart @@ -18,7 +18,7 @@ void main() { setUp(() async { app = Protevus(); http = ProtevusHttp(app, useZone: false); - var auth = AngelAuth( + var auth = ProtevusAuth( serializer: (_) async => 'baz', deserializer: (_) async => user); auth.strategies['local'] = LocalAuthStrategy(