Refactor: changing namespace, imports, re-branding

This commit is contained in:
Patrick Stewart 2024-10-12 03:35:14 -07:00
parent b71744869d
commit 3865bd41df
307 changed files with 1137 additions and 1129 deletions

12
TODO.md
View file

@ -1,12 +0,0 @@
# Development Blueprint
## Short Term Goal
* Update examples
* Update User Guide
## Long Term Goal
* Refactor Angel3 architecture for performance and security
* Improve ORM features
* Improve HTTP performance

View file

View file

@ -1,11 +1,11 @@
# Angel3 Anthentication
# Protevus Anthentication
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_auth?include_prereleases)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM)
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/auth/LICENSE)
[![License](https://img.shields.io/github/license/dart-backend/protevus)](https://github.com/dart-backend/protevus/tree/master/packages/auth/LICENSE)
A complete authentication plugin for Angel3. Inspired by Passport. More details in the [User Guide](https://angel3-docs.dukefirehawk.com/guides/authentication).
A complete authentication plugin for Protevus. Inspired by Passport. More details in the [User Guide](https://angel3-docs.dukefirehawk.com/guides/authentication).
## Bundled Strategies

View file

@ -4,7 +4,7 @@ import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
void main() async {
var app = Angel();
var app = Protevus();
var auth = AngelAuth<User>(
serializer: (user) => user.id ?? '',
deserializer: (id) => fetchAUserByIdSomehow(id));
@ -22,7 +22,7 @@ void main() async {
app.post('/auth/local', auth.authenticate('local'));
var http = AngelHttp(app);
var http = ProtevusHttp(app);
await http.startServer('127.0.0.1', 3000);
print('Listening at http://127.0.0.1:3000');

View file

@ -36,8 +36,8 @@ class User extends Model {
void main() async {
hierarchicalLoggingEnabled = true;
Angel app = Angel(reflector: MirrorsReflector());
AngelHttp angelHttp = AngelHttp(app);
Protevus app = Protevus(reflector: MirrorsReflector());
ProtevusHttp angelHttp = ProtevusHttp(app);
app.use('/users', MapService());
var oldErrorHandler = app.errorHandler;

View file

@ -23,7 +23,7 @@ Future<Map<String, String>> verifier(String? username, String? password) async {
}
}
Future wireAuth(Angel app) async {
Future wireAuth(Protevus app) async {
//auth.strategies['local'] = LocalAuthStrategy(verifier);
auth.strategies['local'] =
LocalAuthStrategy(verifier, forceBasic: true, realm: 'test');
@ -34,8 +34,8 @@ Future wireAuth(Angel app) async {
* Backend for local test cases
*/
void main() async {
Angel app = Angel(reflector: MirrorsReflector());
AngelHttp angelHttp = AngelHttp(app, useZone: false);
Protevus app = Protevus(reflector: MirrorsReflector());
ProtevusHttp angelHttp = ProtevusHttp(app, useZone: false);
await app.configure(wireAuth);
app.get('/hello', (req, res) {

View file

@ -68,7 +68,7 @@ class AuthToken {
if (split.length != 3) {
_log.warning('Invalid JWT');
throw AngelHttpException.notAuthenticated(message: 'Invalid JWT.');
throw ProtevusHttpException.notAuthenticated(message: 'Invalid JWT.');
}
var payloadString = decodeBase64(split[1]);
@ -81,7 +81,7 @@ class AuthToken {
if (split.length != 3) {
_log.warning('Invalid JWT');
throw AngelHttpException.notAuthenticated(message: 'Invalid JWT.');
throw ProtevusHttpException.notAuthenticated(message: 'Invalid JWT.');
}
// var headerString = decodeBase64(split[0]);
@ -91,7 +91,7 @@ class AuthToken {
if (signature != split[2]) {
_log.warning('JWT payload does not match hashed version');
throw AngelHttpException.notAuthenticated(
throw ProtevusHttpException.notAuthenticated(
message: 'JWT payload does not match hashed version.');
}

View file

@ -17,7 +17,7 @@ RequestHandler forceBasicAuth<User>({String? realm}) {
}
res.headers['www-authenticate'] = 'Basic realm="${realm ?? 'angel_auth'}"';
throw AngelHttpException.notAuthenticated();
throw ProtevusHttpException.notAuthenticated();
};
}
@ -28,7 +28,7 @@ RequestHandler requireAuthentication<User>() {
bool reject(ResponseContext res) {
if (throwError) {
res.statusCode = 403;
throw AngelHttpException.forbidden();
throw ProtevusHttpException.forbidden();
} else {
return false;
}

View file

@ -97,7 +97,7 @@ class AngelAuth<User> {
/// Configures an Angel server to decode and validate JSON Web tokens on demand,
/// whenever an instance of [User] is injected.
Future<void> configureServer(Angel app) async {
Future<void> configureServer(Protevus app) async {
/*
if (serializer == null) {
throw StateError(
@ -109,7 +109,7 @@ class AngelAuth<User> {
}
if (app.container == null) {
_log.severe('Angel3 container is null');
_log.severe('Protevus container is null');
throw StateError(
'Angel.container is null. All authentication will fail.');
}
@ -136,7 +136,7 @@ class AngelAuth<User> {
return result;
} else {
_log.warning('JWT is null');
throw AngelHttpException.forbidden();
throw ProtevusHttpException.forbidden();
}
});
@ -223,7 +223,7 @@ class AngelAuth<User> {
if (enforceIp) {
if (req.ip != token.ipAddress) {
_log.warning('JWT cannot be accessed from this IP address');
throw AngelHttpException.forbidden(
throw ProtevusHttpException.forbidden(
message: 'JWT cannot be accessed from this IP address.');
}
}
@ -234,7 +234,7 @@ class AngelAuth<User> {
if (!expiry.isAfter(DateTime.now())) {
_log.warning('Expired JWT');
throw AngelHttpException.forbidden(message: 'Expired JWT.');
throw ProtevusHttpException.forbidden(message: 'Expired JWT.');
}
}
@ -308,13 +308,13 @@ class AngelAuth<User> {
if (jwt == null) {
_log.warning('No JWT provided');
throw AngelHttpException.forbidden(message: 'No JWT provided');
throw ProtevusHttpException.forbidden(message: 'No JWT provided');
} else {
var token = AuthToken.validate(jwt, _hs256);
if (enforceIp) {
if (req.ip != token.ipAddress) {
_log.warning('WT cannot be accessed from this IP address');
throw AngelHttpException.forbidden(
throw ProtevusHttpException.forbidden(
message: 'JWT cannot be accessed from this IP address.');
}
}
@ -339,11 +339,11 @@ class AngelAuth<User> {
return {'data': data, 'token': token.serialize(_hs256)};
}
} catch (e) {
if (e is AngelHttpException) {
if (e is ProtevusHttpException) {
rethrow;
}
_log.warning('Malformed JWT');
throw AngelHttpException.badRequest(message: 'Malformed JWT');
throw ProtevusHttpException.badRequest(message: 'Malformed JWT');
}
}
@ -452,7 +452,7 @@ class AngelAuth<User> {
return false;
} else {
_log.warning('Not authenticated');
throw AngelHttpException.notAuthenticated();
throw ProtevusHttpException.notAuthenticated();
}
}
}

View file

@ -55,7 +55,7 @@ class LocalAuthStrategy<User> extends AuthStrategy<User> {
await verifier(usrPassMatch.group(1), usrPassMatch.group(2));
} else {
_log.warning('Bad request: $invalidMessage');
throw AngelHttpException.badRequest(errors: [invalidMessage]);
throw ProtevusHttpException.badRequest(errors: [invalidMessage]);
}
if (verificationResult == null) {
@ -108,7 +108,7 @@ class LocalAuthStrategy<User> extends AuthStrategy<User> {
}
_log.info('Not authenticated');
throw AngelHttpException.notAuthenticated();
throw ProtevusHttpException.notAuthenticated();
/*
if (verificationResult is Map && verificationResult.isEmpty) {

View file

@ -1,8 +1,8 @@
name: angel3_auth
description: A complete authentication plugin for Angel3. Includes support for stateless JWT tokens, Basic Auth, and more.
description: A complete authentication plugin for Protevus. Includes support for stateless JWT tokens, Basic Auth, and more.
version: 8.2.0
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/auth
repository: https://github.com/dart-backend/protevus/tree/master/packages/auth
environment:
sdk: '>=3.3.0 <4.0.0'
dependencies:

View file

@ -35,8 +35,8 @@ class User extends Model {
}
void main() {
late Angel app;
late AngelHttp angelHttp;
late Protevus app;
late ProtevusHttp angelHttp;
AngelAuth<User> auth;
http.Client? client;
HttpServer server;
@ -45,8 +45,8 @@ void main() {
setUp(() async {
hierarchicalLoggingEnabled = true;
app = Angel(reflector: MirrorsReflector());
angelHttp = AngelHttp(app);
app = Protevus(reflector: MirrorsReflector());
angelHttp = ProtevusHttp(app);
app.use('/users', MapService());
var oldErrorHandler = app.errorHandler;

View file

@ -26,7 +26,7 @@ Future<Map<String, String>> verifier(String? username, String? password) async {
}
}
Future wireAuth(Angel app) async {
Future wireAuth(Protevus app) async {
//auth.serializer = (user) async => 1337;
//auth.deserializer = (id) async => sampleUser;
@ -35,16 +35,16 @@ Future wireAuth(Angel app) async {
}
void main() async {
Angel app;
late AngelHttp angelHttp;
Protevus app;
late ProtevusHttp angelHttp;
late http.Client client;
String? url;
String? basicAuthUrl;
setUp(() async {
client = http.Client();
app = Angel(reflector: MirrorsReflector());
angelHttp = AngelHttp(app, useZone: false);
app = Protevus(reflector: MirrorsReflector());
angelHttp = ProtevusHttp(app, useZone: false);
await app.configure(wireAuth);
app.get('/hello', (req, res) {

View file

@ -1,11 +1,11 @@
# Angel3 OAuth2 Handler
# Protevus OAuth2 Handler
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_auth_oauth2?include_prereleases)
![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)(<https://dart.dev/null-safety>)
[![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM)
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/auth_oauth2/LICENSE)
[![License](https://img.shields.io/github/license/dart-backend/protevus)](https://github.com/dart-backend/protevus/tree/master/packages/auth_oauth2/LICENSE)
Angel3 library for authenticating users with remote identity providers via OAuth2, i.e. Facebook, Google, Azure AD, etc.
Protevus library for authenticating users with remote identity providers via OAuth2, i.e. Facebook, Google, Azure AD, etc.
## Usage

View file

@ -33,9 +33,9 @@ Map<String, dynamic> parseParamsFromGithub(MediaType contentType, String body) {
void main() async {
// Create the server instance.
var app = Angel();
var http = AngelHttp(app);
app.logger = Logger('angel')
var app = Protevus();
var http = ProtevusHttp(app);
app.logger = Logger('protevus')
..onRecord.listen((rec) {
print(rec);
if (rec.error != null) print(rec.error);

View file

@ -1,8 +1,8 @@
name: angel3_auth_oauth2
version: 8.2.0
description: Angel3 library for authenticating users with external identity providers via OAuth2.
description: Protevus library for authenticating users with external identity providers via OAuth2.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/auth_oauth2
repository: https://github.com/dart-backend/protevus/tree/master/packages/auth_oauth2
environment:
sdk: '>=3.3.0 <4.0.0'
dependencies:

View file

@ -1,11 +1,11 @@
# Angel3 Twitter OAuth1
# Protevus Twitter OAuth1
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_auth_twitter?include_prereleases)
![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](<https://dart.dev/null-safety>)
[![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM)
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/auth_twitter/LICENSE)
[![License](https://img.shields.io/github/license/dart-backend/protevus)](https://github.com/dart-backend/protevus/tree/master/packages/auth_twitter/LICENSE)
**Not ready for release**
Angel3 authentication strategy using Twitter OAuth 1.0a.
Protevus authentication strategy using Twitter OAuth 1.0a.
See the [example](example/example.dart);

View file

@ -15,8 +15,8 @@ class _User {
}
void main() async {
var app = Angel();
var http = AngelHttp(app);
var app = Protevus();
var http = ProtevusHttp(app);
var auth = AngelAuth<_User>(
jwtKey: 'AUTH_TWITTER_SECRET',
allowCookie: false,

View file

@ -1,8 +1,8 @@
name: "angel3_auth_twitter"
description: Angel3 authentication strategy for Twitter login. Auto-signs requests.
description: Protevus authentication strategy for Twitter login. Auto-signs requests.
version: 8.0.0
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/auth_twitter
repository: https://github.com/dart-backend/protevus/tree/master/packages/auth_twitter
publish_to: none
environment:
sdk: ">=3.3.0 <4.0.0"

View file

@ -1,11 +1,11 @@
# Angel3 HTTP Cache
# Protevus HTTP Cache
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_cache?include_prereleases)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM)
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/cache/LICENSE)
[![License](https://img.shields.io/github/license/dart-backend/protevus)](https://github.com/dart-backend/protevus/tree/master/packages/cache/LICENSE)
A service that provides HTTP caching to the response data for [Angel3 framework](https://pub.dev/packages/angel3).
A service that provides HTTP caching to the response data for [Protevus framework](https://pub.dev/packages/angel3).
## `CacheService`
@ -40,7 +40,7 @@ void main() async {
## `ResponseCache`
A flexible response cache for Angel3.
A flexible response cache for Protevus.
Use this to improve real and perceived response of Web applications, as well as to memorize expensive responses.

View file

@ -3,7 +3,7 @@ import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
void main() async {
var app = Angel();
var app = Protevus();
app.use(
'/api/todos',
@ -18,7 +18,7 @@ void main() async {
})),
);
var http = AngelHttp(app);
var http = ProtevusHttp(app);
var server = await http.startServer('127.0.0.1', 3000);
print('Listening at http://${server.address.address}:${server.port}');
}

View file

@ -3,7 +3,7 @@ import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
void main() async {
var app = Angel();
var app = Protevus();
// Cache a glob
var cache = ResponseCache()
@ -21,7 +21,7 @@ void main() async {
// Support purging the cache.
app.addRoute('PURGE', '*', (req, res) {
if (req.ip != '127.0.0.1') {
throw AngelHttpException.forbidden();
throw ProtevusHttpException.forbidden();
}
cache.purge(req.uri!.path);
@ -31,7 +31,7 @@ void main() async {
// The response finalizer that actually saves the content
app.responseFinalizers.add(cache.responseFinalizer);
var http = AngelHttp(app);
var http = ProtevusHttp(app);
var server = await http.startServer('127.0.0.1', 3000);
print('Listening at http://${server.address.address}:${server.port}');
}

View file

@ -1,8 +1,8 @@
name: angel3_cache
version: 8.2.0
description: A service that provides HTTP caching to the response data for Angel3
description: A service that provides HTTP caching to the response data for Protevus
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/cache
repository: https://github.com/dart-backend/protevus/tree/master/packages/cache
environment:
sdk: '>=3.4.0 <4.0.0'
dependencies:

View file

@ -21,7 +21,7 @@ Future<void> main() async {
late http.Response response1, response2;
setUp(() async {
var app = Angel();
var app = Protevus();
var cache = ResponseCache()
..patterns.addAll([
//Glob('/*.txt'), // Requires to create folders and files for testing

View file

@ -1,11 +1,11 @@
# Angel3 Client
# Protevus Client
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_client?include_prereleases)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM)
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/client/LICENSE)
[![License](https://img.shields.io/github/license/dart-backend/protevus)](https://github.com/dart-backend/protevus/tree/master/packages/client/LICENSE)
A browser, mobile and command line based client that supports querying Angel3 backend.
A browser, mobile and command line based client that supports querying Protevus backend.
## Usage

View file

@ -1,7 +1,7 @@
import 'package:angel3_client/io.dart' as c;
void main() async {
c.Angel client = c.Rest('http://localhost:3000');
c.Protevus client = c.Rest('http://localhost:3000');
const Map<String, String> user = {'username': 'foo', 'password': 'bar'};

View file

@ -8,8 +8,8 @@ void main() async {
var localOpts =
AngelAuthOptions<Map<String, String>>(canRespondWithJson: true);
Angel app = Angel();
AngelHttp http = AngelHttp(app, useZone: false);
Protevus app = Protevus();
ProtevusHttp http = ProtevusHttp(app, useZone: false);
var auth = AngelAuth(
serializer: (_) async => 'baz', deserializer: (_) async => user);

View file

@ -1,7 +1,7 @@
import 'dart:async';
import 'package:angel3_client/angel3_client.dart';
Future doSomething(Angel app) async {
Future doSomething(Protevus app) async {
var userService = app
.service<String, Map<String, dynamic>>('api/users')
.map(User.fromMap, User.toMap);

View file

@ -8,17 +8,17 @@ import 'package:http/http.dart' as http;
//import 'package:logging/logging.dart';
export 'package:angel3_http_exception/angel3_http_exception.dart';
/// A function that configures an [Angel] client in some way.
typedef AngelConfigurer = FutureOr<void> Function(Angel app);
/// A function that configures an [Protevus] client in some way.
typedef ProtevusConfigurer = FutureOr<void> Function(Protevus app);
/// A function that deserializes data received from the server.
///
/// This is only really necessary in the browser, where `json_god`
/// doesn't work.
typedef AngelDeserializer<T> = T? Function(dynamic x);
typedef ProtevusDeserializer<T> = T? Function(dynamic x);
/// Represents an Angel server that we are querying.
abstract class Angel extends http.BaseClient {
abstract class Protevus extends http.BaseClient {
//final _log = Logger('Angel');
/// A mutable member. When this is set, it holds a JSON Web Token
@ -30,11 +30,11 @@ abstract class Angel extends http.BaseClient {
/// The root URL at which the target server.
final Uri baseUrl;
Angel(baseUrl)
Protevus(baseUrl)
: baseUrl = baseUrl is Uri ? baseUrl : Uri.parse(baseUrl.toString());
/// Fired whenever a WebSocket is successfully authenticated.
Stream<AngelAuthResult> get onAuthenticated;
Stream<ProtevusAuthResult> get onAuthenticated;
/// Authenticates against the server.
///
@ -43,11 +43,11 @@ abstract class Angel extends http.BaseClient {
/// The [type] is appended to the [authEndpoint], ex. `local` becomes `/auth/local`.
///
/// The given [credentials] are sent to server as-is; the request body is sent as JSON.
Future<AngelAuthResult> authenticate(
Future<ProtevusAuthResult> authenticate(
{required String type, credentials, String authEndpoint = '/auth'});
/// Shorthand for authenticating via a JWT string.
Future<AngelAuthResult> reviveJwt(String token,
Future<ProtevusAuthResult> reviveJwt(String token,
{String authEndpoint = '/auth'}) {
return authenticate(
type: 'token',
@ -62,8 +62,8 @@ abstract class Angel extends http.BaseClient {
@override
Future<void> close();
/// Applies an [AngelConfigurer] to this instance.
Future<void> configure(AngelConfigurer configurer) async {
/// Applies an [ProtevusConfigurer] to this instance.
Future<void> configure(ProtevusConfigurer configurer) async {
await configurer(this);
}
@ -80,7 +80,7 @@ abstract class Angel extends http.BaseClient {
/// You can pass a custom [deserializer], which is typically necessary in cases where
/// `dart:mirrors` does not exist.
Service<Id, Data> service<Id, Data>(String path,
{AngelDeserializer<Data>? deserializer});
{ProtevusDeserializer<Data>? deserializer});
//@override
//Future<http.Response> delete(url, {Map<String, String> headers});
@ -105,21 +105,21 @@ abstract class Angel extends http.BaseClient {
}
/// Represents the result of authentication with an Angel server.
class AngelAuthResult {
class ProtevusAuthResult {
String? _token;
final Map<String, dynamic> data = {};
/// The JSON Web token that was sent with this response.
String? get token => _token;
AngelAuthResult({String? token, Map<String, dynamic> data = const {}}) {
ProtevusAuthResult({String? token, Map<String, dynamic> data = const {}}) {
_token = token;
this.data.addAll(data);
}
/// Attempts to deserialize a response from a [Map].
factory AngelAuthResult.fromMap(Map? data) {
final result = AngelAuthResult();
factory ProtevusAuthResult.fromMap(Map? data) {
final result = ProtevusAuthResult();
if (data is Map && data.containsKey('token') && data['token'] is String) {
result._token = data['token'].toString();
@ -141,8 +141,8 @@ class AngelAuthResult {
}
/// Attempts to deserialize a response from a [String].
factory AngelAuthResult.fromJson(String s) =>
AngelAuthResult.fromMap(json.decode(s) as Map?);
factory ProtevusAuthResult.fromJson(String s) =>
ProtevusAuthResult.fromMap(json.decode(s) as Map?);
/// Converts this instance into a JSON-friendly representation.
Map<String, dynamic> toJson() {
@ -171,7 +171,7 @@ abstract class Service<Id, Data> {
Stream<Data> get onRemoved;
/// The Angel instance powering this service.
Angel get app;
Protevus get app;
Future close();
@ -209,7 +209,7 @@ class _MappedService<Id, Data, U> extends Service<Id, U> {
_MappedService(this.inner, this.encoder, this.decoder);
@override
Angel get app => inner.app;
Protevus get app => inner.app;
@override
Future close() => Future.value();

View file

@ -18,22 +18,22 @@ Map<String, String> _buildQuery(Map<String, dynamic>? params) {
bool _invalid(Response response) =>
response.statusCode < 200 || response.statusCode >= 300;
AngelHttpException failure(Response response,
ProtevusHttpException failure(Response response,
{error, String? message, StackTrace? stack}) {
try {
var v = json.decode(response.body);
if (v is Map && (v['is_error'] == true) || v['isError'] == true) {
return AngelHttpException.fromMap(v as Map);
return ProtevusHttpException.fromMap(v as Map);
} else {
return AngelHttpException(
return ProtevusHttpException(
message: message ??
'Unhandled exception while connecting to Angel backend.',
statusCode: response.statusCode,
stackTrace: stack);
}
} catch (e, st) {
return AngelHttpException(
return ProtevusHttpException(
message: message ??
'Angel backend did not return JSON - an error likely occurred.',
statusCode: response.statusCode,
@ -41,22 +41,22 @@ AngelHttpException failure(Response response,
}
}
abstract class BaseAngelClient extends Angel {
abstract class BaseProtevusClient extends Protevus {
final _log = Logger('BaseAngelClient');
final StreamController<AngelAuthResult> _onAuthenticated =
StreamController<AngelAuthResult>();
final StreamController<ProtevusAuthResult> _onAuthenticated =
StreamController<ProtevusAuthResult>();
final List<Service> _services = [];
final BaseClient client;
final Context _p = Context(style: Style.url);
@override
Stream<AngelAuthResult> get onAuthenticated => _onAuthenticated.stream;
Stream<ProtevusAuthResult> get onAuthenticated => _onAuthenticated.stream;
BaseAngelClient(this.client, baseUrl) : super(baseUrl);
BaseProtevusClient(this.client, baseUrl) : super(baseUrl);
@override
Future<AngelAuthResult> authenticate(
Future<ProtevusAuthResult> authenticate(
{String? type, credentials, String authEndpoint = '/auth'}) async {
type ??= 'token';
@ -87,14 +87,14 @@ abstract class BaseAngelClient extends Angel {
var v = jsonDecode(response.body);
if (v is! Map || !v.containsKey('data') || !v.containsKey('token')) {
throw AngelHttpException.notAuthenticated(
throw ProtevusHttpException.notAuthenticated(
message: "Auth endpoint '$url' did not return a proper response.");
}
var r = AngelAuthResult.fromMap(v);
var r = ProtevusAuthResult.fromMap(v);
_onAuthenticated.add(r);
return r;
} on AngelHttpException {
} on ProtevusHttpException {
rethrow;
} catch (e, st) {
_log.severe(st);
@ -153,9 +153,9 @@ abstract class BaseAngelClient extends Angel {
@override
Service<Id, Data> service<Id, Data>(String path,
{Type? type, AngelDeserializer<Data>? deserializer}) {
{Type? type, ProtevusDeserializer<Data>? deserializer}) {
var url = baseUrl.replace(path: _p.join(baseUrl.path, path));
var s = BaseAngelService<Id, Data>(client, this, url,
var s = BaseProtevusService<Id, Data>(client, this, url,
deserializer: deserializer);
_services.add(s);
return s as Service<Id, Data>;
@ -201,14 +201,14 @@ abstract class BaseAngelClient extends Angel {
}
}
class BaseAngelService<Id, Data> extends Service<Id, Data?> {
final _log = Logger('BaseAngelService');
class BaseProtevusService<Id, Data> extends Service<Id, Data?> {
final _log = Logger('BaseProtevusService');
@override
final BaseAngelClient app;
final BaseProtevusClient app;
final Uri baseUrl;
final BaseClient client;
final AngelDeserializer<Data>? deserializer;
final ProtevusDeserializer<Data>? deserializer;
final Context _p = Context(style: Style.url);
@ -247,7 +247,7 @@ class BaseAngelService<Id, Data> extends Service<Id, Data?> {
await _onRemoved.close();
}
BaseAngelService(this.client, this.app, baseUrl, {this.deserializer})
BaseProtevusService(this.client, this.app, baseUrl, {this.deserializer})
: baseUrl = baseUrl is Uri ? baseUrl : Uri.parse(baseUrl.toString());
Data? deserialize(x) {

View file

@ -12,11 +12,11 @@ import 'base_angel_client.dart';
export 'angel3_client.dart';
/// Queries an Angel server via REST.
class Rest extends BaseAngelClient {
class Rest extends BaseProtevusClient {
Rest(String basePath) : super(http.BrowserClient(), basePath);
@override
Future<AngelAuthResult> authenticate(
Future<ProtevusAuthResult> authenticate(
{String? type, credentials, String authEndpoint = '/auth'}) async {
if (type == null || type == 'token') {
if (!window.localStorage.containsKey('token')) {
@ -46,7 +46,7 @@ class Rest extends BaseAngelClient {
t = Timer.periodic(Duration(milliseconds: 500), (timer) {
if (!ctrl.isClosed) {
if (wnd.closed!) {
ctrl.addError(AngelHttpException.notAuthenticated(
ctrl.addError(ProtevusHttpException.notAuthenticated(
message:
errorMessage ?? 'Authentication via popup window failed.'));
ctrl.close();

View file

@ -7,7 +7,7 @@ import 'base_angel_client.dart';
export 'angel3_client.dart';
/// Queries an Angel server via REST.
class Rest extends BaseAngelClient {
class Rest extends BaseProtevusClient {
Rest(String basePath) : super(http.Client() as http.BaseClient, basePath);
@override

View file

@ -11,7 +11,7 @@ import 'base_angel_client.dart';
export 'angel3_client.dart';
/// Queries an Angel server via REST.
class Rest extends BaseAngelClient {
class Rest extends BaseProtevusClient {
//final _log = Logger('REST');
final List<Service> _services = [];
@ -19,7 +19,7 @@ class Rest extends BaseAngelClient {
@override
Service<Id, Data> service<Id, Data>(String path,
{Type? type, AngelDeserializer? deserializer}) {
{Type? type, ProtevusDeserializer? deserializer}) {
var url = baseUrl.replace(path: p.join(baseUrl.path, path));
var s = RestService<Id, Data>(client, this, url, type);
_services.add(s);
@ -43,7 +43,7 @@ class Rest extends BaseAngelClient {
}
/// Queries an Angel service via REST.
class RestService<Id, Data> extends BaseAngelService<Id, Data> {
class RestService<Id, Data> extends BaseProtevusService<Id, Data> {
final _log = Logger('RestService');
final Type? type;

View file

@ -15,18 +15,18 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/angel-dart/angel_client.git"
"url": "git+https://github.com/protevus-dart/angel_client.git"
},
"keywords": [
"angel",
"protevus",
"angel_client"
],
"author": "Tobe O <thosakwe@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/angel-dart/angel_client/issues"
"url": "https://github.com/protevus-dart/angel_client/issues"
},
"homepage": "https://github.com/angel-dart/angel_client#readme",
"homepage": "https://github.com/protevus-dart/angel_client#readme",
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-plugin-add-module-exports": "^0.2.1",

View file

@ -1,8 +1,8 @@
name: angel3_client
version: 8.2.0
description: A browser, mobile and command line based client that supports querying Angel3 servers
description: A browser, mobile and command line based client that supports querying Protevus servers
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/client
repository: https://github.com/dart-backend/protevus/tree/master/packages/client
environment:
sdk: '>=3.3.0 <4.0.0'
dependencies:

View file

@ -9,13 +9,13 @@ const Map<String, String> user = {'username': 'foo', 'password': 'bar'};
var localOpts = AngelAuthOptions<Map<String, String>>(canRespondWithJson: true);
void main() {
late Angel app;
late AngelHttp http;
late c.Angel client;
late Protevus app;
late ProtevusHttp http;
late c.Protevus client;
setUp(() async {
app = Angel();
http = AngelHttp(app, useZone: false);
app = Protevus();
http = ProtevusHttp(app, useZone: false);
var auth = AngelAuth(
serializer: (_) async => 'baz', deserializer: (_) async => user);

View file

@ -8,7 +8,7 @@ import 'package:http/src/streamed_response.dart' as http;
Future<String> read(Stream<List<int>> stream) =>
stream.transform(utf8.decoder).join();
class MockAngel extends BaseAngelClient {
class MockAngel extends BaseProtevusClient {
final SpecClient specClient = SpecClient();
@override

View file

@ -10,13 +10,13 @@ import 'package:test/test.dart';
void main() {
late HttpServer server;
late c.Angel app;
late c.Protevus app;
late c.ServiceList list;
late StreamQueue queue;
setUp(() async {
var serverApp = s.Angel(reflector: MirrorsReflector());
var http = s.AngelHttp(serverApp);
var serverApp = s.Protevus(reflector: MirrorsReflector());
var http = s.ProtevusHttp(serverApp);
serverApp.use('/api/todos', s.MapService(autoIdAndDateFields: false));
server = await http.startServer();

View file

@ -76,5 +76,5 @@ but instead throw an exception.
## 1.0.5
* Now using `package:merge_map` to merge configurations. Resolves
[#5](https://github.com/angel-dart/configuration/issues/5).
[#5](https://github.com/protevus-dart/configuration/issues/5).
* You can now specify a custom `envPath`.

View file

@ -1,11 +1,11 @@
# Angel3 Configuration Loader
# Protevus Configuration Loader
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_configuration?include_prereleases)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM)
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/configuration/LICENSE)
[![License](https://img.shields.io/github/license/dart-backend/protevus)](https://github.com/dart-backend/protevus/tree/master/packages/configuration/LICENSE)
Automatic YAML configuration loader for [Angel3 framework](https://pub.dev/packages/angel3)
Automatic YAML configuration loader for [Protevus framework](https://pub.dev/packages/angel3)
## About

View file

@ -5,7 +5,7 @@ import 'package:angel3_framework/angel3_framework.dart';
import 'package:file/local.dart';
Future<void> main() async {
var app = Angel();
var app = Protevus();
var fs = const LocalFileSystem();
await app.configure(configuration(fs));
}

View file

@ -124,11 +124,11 @@ Future<Map> loadStandaloneConfiguration(FileSystem fileSystem,
/// load from a [overrideEnvironmentName].
///
/// You can also specify a custom [envPath] to load system configuration from.
AngelConfigurer configuration(FileSystem fileSystem,
ProtevusConfigurer configuration(FileSystem fileSystem,
{String directoryPath = './config',
String? overrideEnvironmentName,
String? envPath}) {
return (Angel app) async {
return (Protevus app) async {
var config = await loadStandaloneConfiguration(
fileSystem,
directoryPath: directoryPath,

View file

@ -2,7 +2,7 @@ name: angel3_configuration
version: 8.2.0
description: Automatic YAML application configuration loader for Angel 3, with .env support.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/configuration
repository: https://github.com/dart-backend/protevus/tree/master/packages/configuration
environment:
sdk: '>=3.3.0 <4.0.0'
dependencies:

View file

@ -12,7 +12,7 @@ Future<void> main() async {
Logger.root.onRecord.listen(prettyLog);
// Note: Set ANGEL_ENV to 'development'
var app = Angel(logger: Logger('angel_configuration'));
var app = Protevus(logger: Logger('angel_configuration'));
var fileSystem = const LocalFileSystem();
await app.configure(configuration(
@ -30,7 +30,7 @@ Future<void> main() async {
);
print('Standalone: $config');
expect(config, {
'angel': {'framework': 'cool'},
'protevus': {'framework': 'cool'},
'must_be_null': null,
'artist': 'Timberlake',
'included': true,
@ -56,7 +56,7 @@ Future<void> main() async {
test('will load .env if exists', () {
expect(app.configuration['artist'], 'Timberlake');
expect(app.configuration['angel'], {'framework': 'cool'});
expect(app.configuration['protevus'], {'framework': 'cool'});
});
test('non-existent environment defaults to null', () {

View file

@ -1,6 +1,6 @@
set_via: default
artist: $JUSTIN
angel:
protevus:
framework: $ANGEL_FRAMEWORK
must_be_null: $NONEXISTENT_KEY_FOO_BAR_BAZ_QUUX
merge:

View file

@ -1,11 +1,11 @@
# Angel3 Container
# Protevus Container
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_container?include_prereleases)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM)
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/container/angel_container/LICENSE)
[![License](https://img.shields.io/github/license/dart-backend/protevus)](https://github.com/dart-backend/protevus/tree/master/packages/container/angel_container/LICENSE)
A better IoC container for Angel3, ultimately allowing Angel3 to be used with or without `dart:mirrors` package.
A better IoC container for Protevus, ultimately allowing Protevus to be used with or without `dart:mirrors` package.
```dart
import 'package:angel3_container/mirrors.dart';
@ -40,6 +40,6 @@ A better IoC container for Angel3, ultimately allowing Angel3 to be used with or
var http = AngelHttp(app);
var server = await http.startServer('localhost', 3000);
print("Angel3 server listening at ${http.uri}");
print("Protevus server listening at ${http.uri}");
}
```

View file

@ -1,8 +1,8 @@
name: angel3_container
version: 8.2.0
description: Angel3 hierarchical DI container, and pluggable backends for reflection.
description: Protevus hierarchical DI container, and pluggable backends for reflection.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/container/angel_container
repository: https://github.com/dart-backend/protevus/tree/master/packages/container/angel_container
environment:
sdk: '>=3.3.0 <4.0.0'
dependencies:

View file

@ -1,11 +1,11 @@
# Angel3 Container Generator
# Protevus Container Generator
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_container_generator?include_prereleases)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM)
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/container/angel3_container_generator/LICENSE)
[![License](https://img.shields.io/github/license/dart-backend/protevus)](https://github.com/dart-backend/protevus/tree/master/packages/container/angel3_container_generator/LICENSE)
An alternative container for Angel3 that uses `reflectable` package instead of `dart:mirrors` for reflection. However, `reflectable` has more limited relfection capabilities when compared to `dart:mirrors`.
An alternative container for Protevus that uses `reflectable` package instead of `dart:mirrors` for reflection. However, `reflectable` has more limited relfection capabilities when compared to `dart:mirrors`.
## Usage

View file

@ -2,7 +2,7 @@ name: angel3_container_generator
version: 8.2.0
description: Codegen support for using pkg:reflectable with pkg:angel3_container.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/container/angel_container_generator
repository: https://github.com/dart-backend/protevus/tree/master/packages/container/angel_container_generator
environment:
sdk: '>=3.3.0 <4.0.0'
dependencies:

View file

@ -1,8 +1,8 @@
# Angel3 Http Exception
# Protevus Http Exception
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_http_exception?include_prereleases)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM)
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/http_exception/LICENSE)
[![License](https://img.shields.io/github/license/dart-backend/protevus)](https://github.com/dart-backend/protevus/tree/master/packages/http_exception/LICENSE)
Exception class that can be serialized to JSON and serialized to clients. Angel3's HTTP exception class.
Exception class that can be serialized to JSON and serialized to clients. Protevus's HTTP exception class.

View file

@ -1,4 +1,4 @@
import 'package:angel3_http_exception/angel3_http_exception.dart';
void main() =>
throw AngelHttpException.notFound(message: "Can't find that page!");
throw ProtevusHttpException.notFound(message: "Can't find that page!");

View file

@ -8,7 +8,7 @@ import 'dart:convert';
///
/// Originally inspired by
/// [feathers-errors](https://github.com/feathersjs/feathers-errors).
class AngelHttpException implements Exception {
class ProtevusHttpException implements Exception {
/// A list of errors that occurred when this exception was thrown.
final List<String> errors = [];
@ -24,7 +24,7 @@ class AngelHttpException implements Exception {
/// An HTTP status code this exception will throw.
int statusCode;
AngelHttpException(
ProtevusHttpException(
{this.message = '500 Internal Server Error',
this.stackTrace,
this.statusCode = 500,
@ -49,8 +49,8 @@ class AngelHttpException implements Exception {
return '$statusCode: $message';
}
factory AngelHttpException.fromMap(Map data) {
return AngelHttpException(
factory ProtevusHttpException.fromMap(Map data) {
return ProtevusHttpException(
statusCode: (data['status_code'] ?? data['statusCode'] ?? 500) as int,
message: data['message']?.toString() ?? 'Internal Server Error',
errors: data['errors'] is Iterable
@ -59,64 +59,65 @@ class AngelHttpException implements Exception {
);
}
factory AngelHttpException.fromJson(String str) =>
AngelHttpException.fromMap(json.decode(str) as Map);
factory ProtevusHttpException.fromJson(String str) =>
ProtevusHttpException.fromMap(json.decode(str) as Map);
/// Throws a 400 Bad Request error, including an optional arrray of (validation?)
/// errors you specify.
factory AngelHttpException.badRequest(
factory ProtevusHttpException.badRequest(
{String message = '400 Bad Request',
List<String> errors = const []}) =>
AngelHttpException(message: message, errors: errors, statusCode: 400);
ProtevusHttpException(message: message, errors: errors, statusCode: 400);
/// Throws a 401 Not Authenticated error.
factory AngelHttpException.notAuthenticated(
factory ProtevusHttpException.notAuthenticated(
{String message = '401 Not Authenticated'}) =>
AngelHttpException(message: message, statusCode: 401);
ProtevusHttpException(message: message, statusCode: 401);
/// Throws a 402 Payment Required error.
factory AngelHttpException.paymentRequired(
factory ProtevusHttpException.paymentRequired(
{String message = '402 Payment Required'}) =>
AngelHttpException(message: message, statusCode: 402);
ProtevusHttpException(message: message, statusCode: 402);
/// Throws a 403 Forbidden error.
factory AngelHttpException.forbidden({String message = '403 Forbidden'}) =>
AngelHttpException(message: message, statusCode: 403);
factory ProtevusHttpException.forbidden({String message = '403 Forbidden'}) =>
ProtevusHttpException(message: message, statusCode: 403);
/// Throws a 404 Not Found error.
factory AngelHttpException.notFound({String message = '404 Not Found'}) =>
AngelHttpException(message: message, statusCode: 404);
factory ProtevusHttpException.notFound({String message = '404 Not Found'}) =>
ProtevusHttpException(message: message, statusCode: 404);
/// Throws a 405 Method Not Allowed error.
factory AngelHttpException.methodNotAllowed(
factory ProtevusHttpException.methodNotAllowed(
{String message = '405 Method Not Allowed'}) =>
AngelHttpException(message: message, statusCode: 405);
ProtevusHttpException(message: message, statusCode: 405);
/// Throws a 406 Not Acceptable error.
factory AngelHttpException.notAcceptable(
factory ProtevusHttpException.notAcceptable(
{String message = '406 Not Acceptable'}) =>
AngelHttpException(message: message, statusCode: 406);
ProtevusHttpException(message: message, statusCode: 406);
/// Throws a 408 Timeout error.
factory AngelHttpException.methodTimeout({String message = '408 Timeout'}) =>
AngelHttpException(message: message, statusCode: 408);
factory ProtevusHttpException.methodTimeout(
{String message = '408 Timeout'}) =>
ProtevusHttpException(message: message, statusCode: 408);
/// Throws a 409 Conflict error.
factory AngelHttpException.conflict({String message = '409 Conflict'}) =>
AngelHttpException(message: message, statusCode: 409);
factory ProtevusHttpException.conflict({String message = '409 Conflict'}) =>
ProtevusHttpException(message: message, statusCode: 409);
/// Throws a 422 Not Processable error.
factory AngelHttpException.notProcessable(
factory ProtevusHttpException.notProcessable(
{String message = '422 Not Processable'}) =>
AngelHttpException(message: message, statusCode: 422);
ProtevusHttpException(message: message, statusCode: 422);
/// Throws a 501 Not Implemented error.
factory AngelHttpException.notImplemented(
factory ProtevusHttpException.notImplemented(
{String message = '501 Not Implemented'}) =>
AngelHttpException(message: message, statusCode: 501);
ProtevusHttpException(message: message, statusCode: 501);
/// Throws a 503 Unavailable error.
factory AngelHttpException.unavailable(
factory ProtevusHttpException.unavailable(
{String message = '503 Unavailable'}) =>
AngelHttpException(message: message, statusCode: 503);
ProtevusHttpException(message: message, statusCode: 503);
}

View file

@ -2,7 +2,7 @@ name: angel3_http_exception
version: 8.2.0
description: Exception class that can be serialized to JSON and serialized to clients.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/http_exception
repository: https://github.com/dart-backend/protevus/tree/master/packages/http_exception
environment:
sdk: '>=3.3.0 <4.0.0'
dev_dependencies:

View file

@ -61,7 +61,7 @@
* Require Dart >= 2.16
* Updated `container` to non nullable
* Updated `angel` to non nullable
* Updated `protevus` to non nullable
* Updated `logger` to non nullable
* Refactored error handler
@ -80,7 +80,7 @@
## 4.2.2
* Added `Date` to response header
* Updated `Server: Angel3` response header
* Updated `Server: Protevus` response header
## 4.2.1
@ -103,7 +103,7 @@
## 4.1.1
* Updated link to `Angel3` home page
* Updated link to `Protevus` home page
* Fixed pedantic warnings
## 4.1.0
@ -145,14 +145,14 @@
* This release was originally planned to be `2.0.5`, but it adds several features, and has
therefore been bumped to `2.1.0`.
* Fix a new (did not appear before 2.6/2.7) type error causing compilation to fail.
<https://github.com/angel-dart/framework/issues/249>
<https://github.com/protevus-dart/framework/issues/249>
## 2.0.5-beta
* Make `@Expose()` in `Controller` optional. <https://github.com/angel-dart/angel/issues/107>
* Add `allowHttp1` to `AngelHttp2` constructors. <https://github.com/angel-dart/angel/issues/108>
* Add `deserializeBody` and `decodeBody` to `RequestContext`. <https://github.com/angel-dart/angel/issues/109>
* Add `HostnameRouter`, which allows for routing based on hostname. <https://github.com/angel-dart/angel/issues/110>
* Make `@Expose()` in `Controller` optional. <https://github.com/protevus-dart/protevus/issues/107>
* Add `allowHttp1` to `AngelHttp2` constructors. <https://github.com/protevus-dart/protevus/issues/108>
* Add `deserializeBody` and `decodeBody` to `RequestContext`. <https://github.com/protevus-dart/protevus/issues/109>
* Add `HostnameRouter`, which allows for routing based on hostname. <https://github.com/protevus-dart/protevus/issues/110>
* Default to using `ThrowingReflector`, instead of `EmptyReflector`. This will give a more descriptive
error when trying to use controllers, etc. without reflection enabled.
* `mountController` returns the mounted controller.
@ -167,12 +167,12 @@ error when trying to use controllers, etc. without reflection enabled.
* Prepare for Dart SDK change to `Stream<List<int>>` that are now
`Stream<Uint8List>`.
* Accept any content type if accept header is missing. See
[this PR](https://github.com/angel-dart/framework/pull/239).
[this PR](https://github.com/protevus-dart/framework/pull/239).
## 2.0.3
* Patch up a bug caused by an upstream change to Dart's stream semantics.
See more: <https://github.com/angel-dart/angel/issues/106#issuecomment-499564485>
See more: <https://github.com/protevus-dart/protevus/issues/106#issuecomment-499564485>
## 2.0.2+1
@ -195,7 +195,7 @@ handlers to run, even after the response was closed.
## 2.0.0
* Angel 2! :angel: :rocket:
* Angel 2! :protevus: :rocket:
## 2.0.0-rc.10

View file

@ -1,16 +1,16 @@
# Angel3 Framework
# Protevus Framework
[![Angel3 Framework](../../angel3_logo.png)](https://github.com/dart-backend/angel)
[![Protevus Framework](../../angel3_logo.png)](https://github.com/dart-backend/protevus)
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_framework?include_prereleases)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM)
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/framework/LICENSE)
[![License](https://img.shields.io/github/license/dart-backend/protevus)](https://github.com/dart-backend/protevus/tree/master/packages/framework/LICENSE)
[![melos](https://img.shields.io/badge/maintained%20with-melos-f700ff.svg?style=flat-square)](https://github.com/invertase/melos)
Angel3 framework is a high-powered HTTP server with support for dependency injection, sophisticated routing, authentication, ORM, graphql etc. It is designed to keep the core minimal but extensible through a series of plugin packages. It won't dictate which features, databases or web templating engine to use. This flexibility enable Angel3 framework to grow with your application as new features can be added to handle the new use cases.
Protevus framework is a high-powered HTTP server with support for dependency injection, sophisticated routing, authentication, ORM, graphql etc. It is designed to keep the core minimal but extensible through a series of plugin packages. It won't dictate which features, databases or web templating engine to use. This flexibility enable Protevus framework to grow with your application as new features can be added to handle the new use cases.
This package is the core package of [Angel3](https://github.com/dart-backend/angel). For more information, visit us at [Angel3 Website](https://angel3-framework.web.app).
This package is the core package of [Protevus](https://github.com/dart-backend/protevus). For more information, visit us at [Protevus Website](https://angel3-framework.web.app).
## Installation and Setup
@ -19,10 +19,10 @@ This package is the core package of [Angel3](https://github.com/dart-backend/ang
1. Download and install [Dart](https://dart.dev/get-dart)
2. Clone one of the following starter projects:
* [Angel3 Basic Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-basic)
* [Angel3 ORM Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-orm)
* [Angel3 ORM MySQL Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-orm-mysql)
* [Angel3 Graphql Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-graphql)
* [Protevus Basic Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-basic)
* [Protevus ORM Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-orm)
* [Protevus ORM MySQL Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-orm-mysql)
* [Protevus Graphql Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-graphql)
3. Run the project in development mode (*hot-reloaded* is enabled on file changes).
@ -38,11 +38,11 @@ This package is the core package of [Angel3](https://github.com/dart-backend/ang
5. Run as docker. Edit and build the image with the provided `Dockerfile` file.
### (Option 2) Create a new project with Angel3 CLI
### (Option 2) Create a new project with Protevus CLI
1. Download and install [Dart](https://dart.dev/get-dart)
2. Install the [Angel3 CLI](https://pub.dev/packages/angel3_cli):
2. Install the [Protevus CLI](https://pub.dev/packages/angel3_cli):
```bash
dart pub global activate angel3_cli
@ -74,9 +74,9 @@ The performance benchmark can be found at
[TechEmpower Framework Benchmarks Round 21](https://www.techempower.com/benchmarks/#section=data-r21&test=composite)
### Migrating from Angel to Angel3
### Migrating from Angel to Protevus
Check out [Migrating to Angel3](https://angel3-docs.dukefirehawk.com/migration/angel-2.x.x-to-angel3/migration-guide-3)
Check out [Migrating to Protevus](https://angel3-docs.dukefirehawk.com/migration/protevus-2.x.x-to-angel3/migration-guide-3)
## Donation & Support

View file

@ -8,14 +8,14 @@ void main() async {
Logger.root.onRecord.listen(print);
// Create our server.
var app = Angel(logger: Logger('angel'), reflector: MirrorsReflector());
var http = AngelHttp(app);
var app = Protevus(logger: Logger('protevus'), reflector: MirrorsReflector());
var http = ProtevusHttp(app);
await app.mountController<ArtistsController>();
// Simple fallback to throw a 404 on unknown paths.
app.fallback((req, res) {
throw AngelHttpException.notFound(
throw ProtevusHttpException.notFound(
message: 'Unknown path: "${req.uri!.path}"',
);
});

View file

@ -6,8 +6,8 @@ import 'package:angel3_framework/http.dart';
import 'package:logging/logging.dart';
void main() async {
var app = Angel(reflector: MirrorsReflector())
..logger = (Logger('angel')
var app = Protevus(reflector: MirrorsReflector())
..logger = (Logger('protevus')
..onRecord.listen((rec) {
print(rec);
if (rec.error != null) print(rec.error);
@ -18,7 +18,7 @@ void main() async {
app.fallback(
(req, res) => Future.error('Throwing just because I feel like!'));
var http = AngelHttp(app);
var http = ProtevusHttp(app);
HttpServer? server = await http.startServer('127.0.0.1', 3000);
var url = 'http://${server.address.address}:${server.port}';
print('Listening at $url');

View file

@ -3,14 +3,14 @@ import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
import 'package:logging/logging.dart';
Future<void> apiConfigurer(Angel app) async {
Future<void> apiConfigurer(Protevus app) async {
app.get('/', (req, res) => 'Hello, API!');
app.fallback((req, res) {
return 'fallback on ${req.uri} (within the API)';
});
}
Future<void> frontendConfigurer(Angel app) async {
Future<void> frontendConfigurer(Protevus app) async {
app.fallback((req, res) => '(usually an index page would be shown here.)');
}
@ -19,8 +19,8 @@ void main() async {
hierarchicalLoggingEnabled = true;
//Logger.root.onRecord.listen(prettyLog);
var app = Angel(logger: Logger('angel'));
var http = AngelHttp(app);
var app = Protevus(logger: Logger('protevus'));
var http = ProtevusHttp(app);
var multiHost = HostnameRouter.configure({
'api.localhost:3000': apiConfigurer,
'localhost:3000': frontendConfigurer,

View file

@ -6,8 +6,8 @@ import 'package:file/local.dart';
import 'package:logging/logging.dart';
void main() async {
var app = Angel();
app.logger = Logger('angel')
var app = Protevus();
app.logger = Logger('protevus')
..onRecord.listen((rec) {
print(rec);
if (rec.error != null) print(rec.error);
@ -35,8 +35,8 @@ void main() async {
st);
}
var http1 = AngelHttp(app);
var http2 = AngelHttp2(app, ctx);
var http1 = ProtevusHttp(app);
var http2 = ProtevusHttp2(app, ctx);
// HTTP/1.x requests will fallback to `AngelHttp`
http2.onHttp1.listen(http1.handleRequest);

View file

@ -6,16 +6,16 @@ import 'package:logging/logging.dart';
import 'common.dart';
void main() async {
var app = Angel()
var app = Protevus()
..encoders.addAll({
'gzip': gzip.encoder,
'deflate': zlib.encoder,
});
app.logger = Logger('angel')..onRecord.listen(dumpError);
app.logger = Logger('protevus')..onRecord.listen(dumpError);
app.get('/', (req, res) => 'Hello HTTP/2!!!');
app.fallback((req, res) => throw AngelHttpException.notFound(
app.fallback((req, res) => throw ProtevusHttpException.notFound(
message: 'No file exists at ${req.uri}'));
var ctx = SecurityContext()
@ -32,8 +32,8 @@ void main() async {
);
}
var http1 = AngelHttp(app);
var http2 = AngelHttp2(app, ctx);
var http1 = ProtevusHttp(app);
var http2 = ProtevusHttp2(app, ctx);
// HTTP/1.x requests will fallback to `AngelHttp`
http2.onHttp1.listen(http1.handleRequest);

View file

@ -6,8 +6,8 @@ import 'package:file/local.dart';
import 'package:logging/logging.dart';
void main() async {
var app = Angel();
app.logger = Logger('angel')
var app = Protevus();
app.logger = Logger('protevus')
..onRecord.listen((rec) {
print(rec);
if (rec.error != null) print(rec.error);
@ -51,8 +51,8 @@ void main() async {
st);
}
var http1 = AngelHttp(app);
var http2 = AngelHttp2(app, ctx);
var http1 = ProtevusHttp(app);
var http2 = ProtevusHttp2(app, ctx);
// HTTP/1.x requests will fallback to `AngelHttp`
http2.onHttp1.listen(http1.handleRequest);

View file

@ -31,9 +31,9 @@ void main() async {
}
void serverMain(_) async {
var app = Angel();
var app = Protevus();
var http =
AngelHttp.custom(app, startShared, useZone: false); // Run a cluster
ProtevusHttp.custom(app, startShared, useZone: false); // Run a cluster
app.get('/', (req, res) {
return res.serialize({

View file

@ -8,8 +8,8 @@ void main() async {
//Logger.root.onRecord.listen(prettyLog);
// Create our server.
var app = Angel(
logger: Logger('angel'),
var app = Protevus(
logger: Logger('protevus'),
reflector: MirrorsReflector(),
);
@ -41,12 +41,12 @@ void main() async {
// Simple fallback to throw a 404 on unknown paths.
app.fallback((req, res) {
throw AngelHttpException.notFound(
throw ProtevusHttpException.notFound(
message: 'Unknown path: "${req.uri!.path}"',
);
});
var http = AngelHttp(app);
var http = ProtevusHttp(app);
var server = await http.startServer('127.0.0.1', 3000);
var url = 'http://${server.address.address}:${server.port}';
print('Listening at $url');

View file

@ -8,15 +8,15 @@ void main() async {
Logger.root.onRecord.listen(print);
// Create our server.
var app = Angel(
logger: Logger('angel'),
var app = Protevus(
logger: Logger('protevus'),
reflector: MirrorsReflector(),
);
// Create a RESTful service that manages an in-memory collection.
app.use('/api/todos', MapService());
var http = AngelHttp(app);
var http = ProtevusHttp(app);
await http.startServer('127.0.0.1', 0);
print('Listening at ${http.uri}');
}

View file

@ -2,8 +2,8 @@ import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
void main() async {
var app = Angel();
var http = AngelHttp(app);
var app = Protevus();
var http = ProtevusHttp(app);
app.fallback((req, res) {
res.statusCode = 304;

View file

@ -3,7 +3,7 @@ import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
void main() async {
var app = Angel(reflector: MirrorsReflector());
var app = Protevus(reflector: MirrorsReflector());
app.viewGenerator = (name, [data]) async =>
'View generator invoked with name $name and data: $data';
@ -11,7 +11,7 @@ void main() async {
// Index route. Returns JSON.
app.get('/', (req, res) => res.render('index', {'foo': 'bar'}));
var http = AngelHttp(app);
var http = ProtevusHttp(app);
var server = await http.startServer('127.0.0.1', 3000);
var url = 'http://${server.address.address}:${server.port}';
print('Listening at $url');

View file

@ -9,10 +9,10 @@ import '../core/core.dart';
/// Supports grouping routes with shared functionality.
class Controller {
Angel? _app;
Protevus? _app;
/// The [Angel] application powering this controller.
Angel get app {
/// The [Protevus] application powering this controller.
Protevus get app {
if (_app == null) {
throw ArgumentError("Angel is not instantiated.");
}
@ -38,7 +38,7 @@ class Controller {
/// Applies routes, DI, and other configuration to an [app].
@mustCallSuper
Future<void> configureServer(Angel app) async {
Future<void> configureServer(Protevus app) async {
_app = app;
if (injectSingleton != false) {

View file

@ -17,7 +17,7 @@ abstract class Driver<
Server extends Stream<Request>,
RequestContextType extends RequestContext,
ResponseContextType extends ResponseContext> {
final Angel app;
final Protevus app;
final bool useZone;
bool _closed = false;
@ -170,23 +170,23 @@ abstract class Driver<
return f.catchError((e, StackTrace st) {
if (e is FormatException) {
throw AngelHttpException.badRequest(message: e.message)
throw ProtevusHttpException.badRequest(message: e.message)
..stackTrace = st;
}
throw AngelHttpException(
throw ProtevusHttpException(
stackTrace: st,
statusCode: (e is AngelHttpException) ? e.statusCode : 500,
statusCode: (e is ProtevusHttpException) ? e.statusCode : 500,
message: e?.toString() ?? '500 Internal Server Error');
}, test: (e) => e is AngelHttpException).catchError(
}, test: (e) => e is ProtevusHttpException).catchError(
(ee, StackTrace st) {
//print(">>>> Framework error: $ee");
//var t = (st).runtimeType;
//print(">>>> StackTrace: $t");
AngelHttpException e;
if (ee is AngelHttpException) {
ProtevusHttpException e;
if (ee is ProtevusHttpException) {
e = ee;
} else {
e = AngelHttpException(
e = ProtevusHttpException(
stackTrace: st,
statusCode: 500,
message: ee?.toString() ?? '500 Internal Server Error');
@ -196,7 +196,8 @@ abstract class Driver<
var trace = Trace.from(StackTrace.current).terse;
app.logger.severe(e.message, error, trace);
return handleAngelHttpException(e, st, req, res, request, response);
return handleProtevusHttpException(
e, st, req, res, request, response);
});
} else {
var zoneSpec = ZoneSpecification(
@ -208,20 +209,20 @@ abstract class Driver<
// TODO: To be revisited
Future(() {
AngelHttpException e;
ProtevusHttpException e;
if (error is FormatException) {
e = AngelHttpException.badRequest(message: error.message);
} else if (error is AngelHttpException) {
e = ProtevusHttpException.badRequest(message: error.message);
} else if (error is ProtevusHttpException) {
e = error;
} else {
e = AngelHttpException(
e = ProtevusHttpException(
stackTrace: stackTrace, message: error.toString());
}
app.logger.severe(e.message, error, trace);
return handleAngelHttpException(
return handleProtevusHttpException(
e, trace, req, res, request, response);
}).catchError((e, StackTrace st) {
var trace = Trace.from(st).terse;
@ -252,9 +253,9 @@ abstract class Driver<
});
}
/// Handles an [AngelHttpException].
Future handleAngelHttpException(
AngelHttpException e,
/// Handles an [ProtevusHttpException].
Future handleProtevusHttpException(
ProtevusHttpException e,
StackTrace st,
RequestContext? req,
ResponseContext? res,
@ -384,7 +385,7 @@ abstract class Driver<
MiddlewarePipelineIterator<RequestHandler> it,
RequestContextType req,
ResponseContextType res,
Angel app) async {
Protevus app) async {
var broken = false;
while (it.moveNext()) {
var current = it.current.handlers.iterator;

View file

@ -1,15 +1,15 @@
import 'dart:io';
/// A constant instance of [AngelEnv].
const AngelEnvironment angelEnv = AngelEnvironment();
const ProtevusEnvironment angelEnv = ProtevusEnvironment();
/// Queries the environment's `ANGEL_ENV` value.
class AngelEnvironment {
class ProtevusEnvironment {
final String? _customValue;
/// You can optionally provide a custom value, in order to override the system's
/// value.
const AngelEnvironment([this._customValue]);
const ProtevusEnvironment([this._customValue]);
/// Returns the value of the `ANGEL_ENV` variable; defaults to `'development'`.
String get value =>

View file

@ -98,7 +98,7 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
}
/// Adds hooks to this instance.
void addHooks(Angel app) {
void addHooks(Protevus app) {
var hooks = getAnnotation<Hooks>(inner, app.container.reflector);
var before = <HookedServiceEventListener<Id, Data, T>>[];
var after = <HookedServiceEventListener<Id, Data, T>>[];

View file

@ -24,13 +24,13 @@ import 'server.dart';
/// * `example.*` -> `/example\./[^$]*`
/// * `example.+` -> `/example\./[^$]+`
class HostnameRouter {
final Map<Pattern, Angel> _apps = {};
final Map<Pattern, FutureOr<Angel> Function()> _creators = {};
final Map<Pattern, Protevus> _apps = {};
final Map<Pattern, FutureOr<Protevus> Function()> _creators = {};
final List<Pattern> _patterns = [];
HostnameRouter(
{Map<Pattern, Angel> apps = const {},
Map<Pattern, FutureOr<Angel> Function()> creators = const {}}) {
{Map<Pattern, Protevus> apps = const {},
Map<Pattern, FutureOr<Protevus> Function()> creators = const {}}) {
Map<Pattern, V> parseMap<V>(Map<Pattern, V> map) {
return map.map((p, c) {
Pattern pp;
@ -55,16 +55,16 @@ class HostnameRouter {
}
factory HostnameRouter.configure(
Map<Pattern, FutureOr<void> Function(Angel)> configurers,
Map<Pattern, FutureOr<void> Function(Protevus)> configurers,
{Reflector reflector = const EmptyReflector(),
AngelEnvironment environment = angelEnv,
ProtevusEnvironment environment = angelEnv,
Logger? logger,
bool allowMethodOverrides = true,
FutureOr<String> Function(dynamic)? serializer,
ViewGenerator? viewGenerator}) {
var creators = configurers.map((p, c) {
return MapEntry(p, () async {
var app = Angel(
var app = Protevus(
reflector: reflector,
environment: environment,
logger: logger,

View file

@ -72,7 +72,7 @@ class MapService extends Service<String?, Map<String, dynamic>> {
Future<Map<String, dynamic>> read(String? id,
[Map<String, dynamic>? params]) {
return Future.value(items.firstWhere(_matchesId(id),
orElse: (() => throw AngelHttpException.notFound(
orElse: (() => throw ProtevusHttpException.notFound(
message: 'No record found for ID $id'))));
}
@ -127,7 +127,7 @@ class MapService extends Service<String?, Map<String, dynamic>> {
return read(id).then((old) {
if (!items.remove(old)) {
throw AngelHttpException.notFound(
throw ProtevusHttpException.notFound(
message: 'No record found for ID $id');
}
@ -152,7 +152,7 @@ class MapService extends Service<String?, Map<String, dynamic>> {
// Remove everything...
if (!(allowRemoveAll == true ||
params?.containsKey('provider') != true)) {
throw AngelHttpException.forbidden(
throw ProtevusHttpException.forbidden(
message: 'Clients are not allowed to delete all items.');
} else {
items.clear();
@ -164,7 +164,7 @@ class MapService extends Service<String?, Map<String, dynamic>> {
if (items.remove(result)) {
return result;
} else {
throw AngelHttpException.notFound(
throw ProtevusHttpException.notFound(
message: 'No record found for ID $id');
}
});

View file

@ -103,15 +103,15 @@ class Parameter {
/// Returns an error that can be thrown when the parameter is not present.
Object? get error {
if (cookie?.isNotEmpty == true) {
return AngelHttpException.badRequest(
return ProtevusHttpException.badRequest(
message: 'Missing required cookie "$cookie".');
}
if (header?.isNotEmpty == true) {
return AngelHttpException.badRequest(
return ProtevusHttpException.badRequest(
message: 'Missing required header "$header".');
}
if (query?.isNotEmpty == true) {
return AngelHttpException.badRequest(
return ProtevusHttpException.badRequest(
message: 'Missing required query parameter "$query".');
}
if (session?.isNotEmpty == true) {

View file

@ -18,13 +18,13 @@ import 'package:logging/logging.dart';
import 'metadata.dart';
import 'response_context.dart';
import 'routable.dart';
import 'server.dart' show Angel;
import 'server.dart' show Protevus;
part 'injection.dart';
/// A convenience wrapper around an incoming [RawRequest].
abstract class RequestContext<RawRequest> {
/// Similar to [Angel.shutdownHooks], allows for logic to be executed
/// Similar to [Protevus.shutdownHooks], allows for logic to be executed
/// when a [RequestContext] is done being processed.
final _log = Logger('RequestContext');
@ -46,8 +46,8 @@ abstract class RequestContext<RawRequest> {
/// Additional params to be passed to services.
final Map<String, dynamic> serviceParams = {};
/// The [Angel] instance that is responding to this request.
Angel? app;
/// The [Protevus] instance that is responding to this request.
Protevus? app;
/// Any cookies sent with this request.
List<Cookie> get cookies => <Cookie>[];

View file

@ -13,7 +13,7 @@ import 'package:mime/mime.dart';
import 'controller.dart';
import 'request_context.dart';
import 'server.dart' show Angel;
import 'server.dart' show Protevus;
final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)');
@ -22,15 +22,15 @@ abstract class ResponseContext<RawResponse>
implements StreamConsumer<List<int>>, StreamSink<List<int>>, StringSink {
final Map properties = {};
final CaseInsensitiveMap<String> _headers = CaseInsensitiveMap<String>.from(
{'content-type': 'text/plain', 'server': 'Angel3'});
{'content-type': 'text/plain', 'server': 'Protevus'});
//final log = Logger('ResponseContext');
Completer? _done;
int _statusCode = 200;
/// The [Angel] instance that is sending a response.
Angel? app;
/// The [Protevus] instance that is sending a response.
Protevus? app;
/// Is `Transfer-Encoding` chunked?
bool? chunked;

View file

@ -21,20 +21,20 @@ import 'service.dart';
//final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)');
/// A function that configures an [Angel] server.
typedef AngelConfigurer = FutureOr<void> Function(Angel app);
/// A function that configures an [Protevus] server.
typedef ProtevusConfigurer = FutureOr<void> Function(Protevus app);
/// A function that asynchronously generates a view from the given path and data.
typedef ViewGenerator = FutureOr<String> Function(String path,
[Map<String, dynamic>? data]);
/// A function that handles error
typedef AngelErrorHandler = dynamic Function(
AngelHttpException e, RequestContext req, ResponseContext res);
typedef ProtevusErrorHandler = dynamic Function(
ProtevusHttpException e, RequestContext req, ResponseContext res);
/// The default error handler for [Angel] server
/// The default error handler for [Protevus] server
Future<bool> _defaultErrorHandler(
AngelHttpException e, RequestContext req, ResponseContext res) async {
ProtevusHttpException e, RequestContext req, ResponseContext res) async {
if (!req.accepts('text/html', strict: true) &&
(req.accepts('application/json') ||
req.accepts('application/javascript'))) {
@ -65,7 +65,7 @@ Logger _defaultLogger() {
if (rec.error != null) {
var err = rec.error;
if (err is AngelHttpException && err.statusCode != 500) return;
if (err is ProtevusHttpException && err.statusCode != 500) return;
print('${rec.message} \n');
print(rec.error);
if (rec.stackTrace != null) {
@ -78,18 +78,18 @@ Logger _defaultLogger() {
}
/// A powerful real-time/REST/MVC server class.
class Angel extends Routable {
class Protevus extends Routable {
static Future<String> _noViewEngineConfigured(String view, [Map? data]) =>
Future.value('No view engine has been configured yet.');
final List<Angel> _children = [];
final List<Protevus> _children = [];
final Map<
String,
Tuple4<List, Map<String, dynamic>, ParseResult<RouteResult>,
MiddlewarePipeline>> handlerCache = HashMap();
Router<RequestHandler>? _flattened;
Angel? _parent;
Protevus? _parent;
/// A global Map of converters that can transform responses bodies.
final Map<String, Converter<List<int>, List<int>>> encoders = {};
@ -114,20 +114,20 @@ class Angel extends Routable {
bool allowMethodOverrides = true;
/// All child application mounted on this instance.
List<Angel> get children => List<Angel>.unmodifiable(_children);
List<Protevus> get children => List<Protevus>.unmodifiable(_children);
final Map<Pattern, Controller> _controllers = {};
/// A set of [Controller] objects that have been loaded into the application.
Map<Pattern, Controller> get controllers => _controllers;
/// The [AngelEnvironment] in which the application is running.
/// The [ProtevusEnvironment] in which the application is running.
///
/// By default, it is automatically inferred.
final AngelEnvironment environment;
final ProtevusEnvironment environment;
/// Returns the parent instance of this application, if any.
Angel? get parent => _parent;
Protevus? get parent => _parent;
/// Outputs diagnostics and debug messages.
Logger _logger = _defaultLogger();
@ -145,12 +145,12 @@ class Angel extends Routable {
/// Plug-ins to be called right before server startup.
///
/// If the server is never started, they will never be called.
final List<AngelConfigurer> startupHooks = [];
final List<ProtevusConfigurer> startupHooks = [];
/// Plug-ins to be called right before server shutdown.
///
/// If the server is never [close]d, they will never be called.
final List<AngelConfigurer> shutdownHooks = [];
final List<ProtevusConfigurer> shutdownHooks = [];
/// Always run before responses are sent.
///
@ -162,8 +162,8 @@ class Angel extends Routable {
/// Called by [ResponseContext]@`render`.
ViewGenerator? viewGenerator = _noViewEngineConfigured;
/// The handler currently configured to run on [AngelHttpException]s.
AngelErrorHandler errorHandler = _defaultErrorHandler;
/// The handler currently configured to run on [ProtevusHttpException]s.
ProtevusErrorHandler errorHandler = _defaultErrorHandler;
@override
Route<RequestHandler> addRoute(
@ -189,7 +189,7 @@ class Angel extends Routable {
'This route will be ignored, and no requests will ever reach it.');
}
if (router is Angel) {
if (router is Protevus) {
router._parent = this;
_children.add(router);
}
@ -199,11 +199,11 @@ class Angel extends Routable {
/// Loads some base dependencies into the service container.
void bootstrapContainer() {
if (runtimeType != Angel) {
if (runtimeType != Protevus) {
container.registerSingleton(this);
}
container.registerSingleton<Angel>(this);
container.registerSingleton<Protevus>(this);
container.registerSingleton<Routable>(this);
container.registerSingleton<Router>(this);
}
@ -358,8 +358,8 @@ class Angel extends Routable {
// return closureMirror.apply(args).reflectee;
}
/// Applies an [AngelConfigurer] to this instance.
Future configure(AngelConfigurer configurer) {
/// Applies an [ProtevusConfigurer] to this instance.
Future configure(ProtevusConfigurer configurer) {
return Future.sync(() => configurer(this));
}
@ -394,9 +394,9 @@ class Angel extends Routable {
'Features like controllers, constructor dependency injection, and `ioc` require reflection, '
'and will not work without it.\n\n'
'For more, see the documentation:\n'
'https://docs.angel-dart.dev/guides/dependency-injection#enabling-dart-mirrors-or-other-reflection';
'https://docs.protevus-dart.dev/guides/dependency-injection#enabling-dart-mirrors-or-other-reflection';
Angel(
Protevus(
{Reflector reflector =
const ThrowingReflector(errorMessage: _reflectionErrorMessage),
this.environment = angelEnv,

View file

@ -67,18 +67,18 @@ class Service<Id, Data> extends Routable {
/// Handlers that must run to ensure this service's functionality.
List<RequestHandler> get bootstrappers => [];
/// The [Angel] app powering this service.
Angel? _app;
/// The [Protevus] app powering this service.
Protevus? _app;
Angel get app {
Protevus get app {
if (_app == null) {
throw ArgumentError("Angel is not initialized");
}
return _app!;
}
set app(Angel angel) {
_app = angel;
set app(Protevus protevus) {
_app = protevus;
}
bool get isAppActive => _app != null;
@ -94,7 +94,7 @@ class Service<Id, Data> extends Routable {
_readData ??= (req, res) {
if (req.bodyAsObject is! Data) {
throw AngelHttpException.badRequest(
throw ProtevusHttpException.badRequest(
message:
'Invalid request body. Expected $Data; found ${req.bodyAsObject} instead.');
} else {
@ -123,7 +123,7 @@ class Service<Id, Data> extends Routable {
String errorMessage = 'No record was found matching the given query.']) {
return index(params).then((result) {
if (result.isEmpty) {
throw AngelHttpException.notFound(message: errorMessage);
throw ProtevusHttpException.notFound(message: errorMessage);
} else {
return result.first;
}
@ -132,12 +132,12 @@ class Service<Id, Data> extends Routable {
/// Retrieves all resources.
Future<List<Data>> index([Map<String, dynamic>? params]) {
throw AngelHttpException.methodNotAllowed();
throw ProtevusHttpException.methodNotAllowed();
}
/// Retrieves the desired resource.
Future<Data> read(Id id, [Map<String, dynamic>? params]) {
throw AngelHttpException.methodNotAllowed();
throw ProtevusHttpException.methodNotAllowed();
}
/// Reads multiple resources at once.
@ -150,22 +150,22 @@ class Service<Id, Data> extends Routable {
/// Creates a resource.
Future<Data> create(Data data, [Map<String, dynamic>? params]) {
throw AngelHttpException.methodNotAllowed();
throw ProtevusHttpException.methodNotAllowed();
}
/// Modifies a resource.
Future<Data> modify(Id id, Data data, [Map<String, dynamic>? params]) {
throw AngelHttpException.methodNotAllowed();
throw ProtevusHttpException.methodNotAllowed();
}
/// Overwrites a resource.
Future<Data> update(Id id, Data data, [Map<String, dynamic>? params]) {
throw AngelHttpException.methodNotAllowed();
throw ProtevusHttpException.methodNotAllowed();
}
/// Removes the given resource.
Future<Data> remove(Id id, [Map<String, dynamic>? params]) {
throw AngelHttpException.methodNotAllowed();
throw ProtevusHttpException.methodNotAllowed();
}
/// Creates an [AnonymousService] that wraps over this one, and maps input and output
@ -371,8 +371,8 @@ class Service<Id, Data> extends Routable {
]);
// REST compliance
put('/', (req, res) => throw AngelHttpException.notFound());
patch('/', (req, res) => throw AngelHttpException.notFound());
put('/', (req, res) => throw ProtevusHttpException.notFound());
patch('/', (req, res) => throw ProtevusHttpException.notFound());
}
/// Invoked when this service is wrapped within a [HookedService].

View file

@ -18,7 +18,7 @@ final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)');
typedef ServerGeneratorType = Future<HttpServer> Function(dynamic, int);
/// Adapts `dart:io`'s [HttpServer] to serve Angel.
class AngelHttp extends Driver<HttpRequest, HttpResponse, HttpServer,
class ProtevusHttp extends Driver<HttpRequest, HttpResponse, HttpServer,
HttpRequestContext, HttpResponseContext> {
@override
Uri get uri {
@ -26,22 +26,23 @@ class AngelHttp extends Driver<HttpRequest, HttpResponse, HttpServer,
scheme: 'http', host: server?.address.address, port: server?.port);
}
AngelHttp._(super.app, super.serverGenerator, bool useZone)
ProtevusHttp._(super.app, super.serverGenerator, bool useZone)
: super(useZone: useZone);
factory AngelHttp(Angel app, {bool useZone = true}) {
return AngelHttp._(app, HttpServer.bind, useZone);
factory ProtevusHttp(Protevus app, {bool useZone = true}) {
return ProtevusHttp._(app, HttpServer.bind, useZone);
}
/// An instance mounted on a server started by the [serverGenerator].
factory AngelHttp.custom(Angel app, ServerGeneratorType serverGenerator,
factory ProtevusHttp.custom(Protevus app, ServerGeneratorType serverGenerator,
{bool useZone = true, Map<String, String> headers = const {}}) {
return AngelHttp._(app, serverGenerator, useZone);
return ProtevusHttp._(app, serverGenerator, useZone);
}
factory AngelHttp.fromSecurityContext(Angel app, SecurityContext context,
factory ProtevusHttp.fromSecurityContext(
Protevus app, SecurityContext context,
{bool useZone = true}) {
return AngelHttp._(app, (address, int port) {
return ProtevusHttp._(app, (address, int port) {
return HttpServer.bindSecure(address, port, context);
}, useZone);
}
@ -51,8 +52,8 @@ class AngelHttp extends Driver<HttpRequest, HttpResponse, HttpServer,
/// Provide paths to a certificate chain and server key (both .pem).
/// If no password is provided, a random one will be generated upon running
/// the server.
factory AngelHttp.secure(
Angel app, String certificateChainPath, String serverKeyPath,
factory ProtevusHttp.secure(
Protevus app, String certificateChainPath, String serverKeyPath,
{String? password, bool useZone = true}) {
var certificateChain =
Platform.script.resolve(certificateChainPath).toFilePath();
@ -61,7 +62,8 @@ class AngelHttp extends Driver<HttpRequest, HttpResponse, HttpServer,
serverContext.useCertificateChain(certificateChain, password: password);
serverContext.usePrivateKey(serverKey, password: password);
return AngelHttp.fromSecurityContext(app, serverContext, useZone: useZone);
return ProtevusHttp.fromSecurityContext(app, serverContext,
useZone: useZone);
}
Future handleRequest(HttpRequest request) =>

View file

@ -77,7 +77,7 @@ class HttpRequestContext extends RequestContext<HttpRequest?> {
/// Magically transforms an [HttpRequest] into a [RequestContext].
static Future<HttpRequestContext> from(
HttpRequest request, Angel app, String path) {
HttpRequest request, Protevus app, String path) {
var ctx = HttpRequestContext().._container = app.container.createChild();
var override = request.method;

View file

@ -18,7 +18,7 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
final HttpRequestContext? _correspondingRequest;
bool _isDetached = false, _isClosed = false, _streamInitialized = false;
HttpResponseContext(this.rawResponse, Angel? app,
HttpResponseContext(this.rawResponse, Protevus? app,
[this._correspondingRequest]) {
this.app = app;
}

View file

@ -16,19 +16,19 @@ Future<SecureServerSocket> startSharedHttp2(
}
/// Adapts `package:http2`'s [ServerTransportConnection] to serve Angel.
class AngelHttp2 extends Driver<Socket, ServerTransportStream,
class ProtevusHttp2 extends Driver<Socket, ServerTransportStream,
SecureServerSocket, Http2RequestContext, Http2ResponseContext> {
final ServerSettings? settings;
late AngelHttp _http;
late ProtevusHttp _http;
final StreamController<HttpRequest> _onHttp1 = StreamController();
final Map<String, MockHttpSession> _sessions = {};
final Uuid _uuid = Uuid();
_AngelHttp2ServerSocket? _artificial;
_ProtevusHttp2ServerSocket? _artificial;
SecureServerSocket? get socket => _artificial;
AngelHttp2._(
Angel app,
ProtevusHttp2._(
Protevus app,
Future<SecureServerSocket> Function(dynamic, int) serverGenerator,
bool useZone,
bool allowHttp1,
@ -39,21 +39,21 @@ class AngelHttp2 extends Driver<Socket, ServerTransportStream,
useZone: useZone,
) {
if (allowHttp1) {
_http = AngelHttp(app, useZone: useZone);
_http = ProtevusHttp(app, useZone: useZone);
onHttp1.listen(_http.handleRequest);
}
}
factory AngelHttp2(Angel app, SecurityContext securityContext,
factory ProtevusHttp2(Protevus app, SecurityContext securityContext,
{bool useZone = true,
bool allowHttp1 = false,
ServerSettings? settings}) {
return AngelHttp2.custom(app, securityContext, SecureServerSocket.bind,
return ProtevusHttp2.custom(app, securityContext, SecureServerSocket.bind,
allowHttp1: allowHttp1, settings: settings);
}
factory AngelHttp2.custom(
Angel app,
factory ProtevusHttp2.custom(
Protevus app,
SecurityContext ctx,
Future<SecureServerSocket> Function(
InternetAddress? address, int port, SecurityContext ctx)
@ -61,7 +61,7 @@ class AngelHttp2 extends Driver<Socket, ServerTransportStream,
{bool useZone = true,
bool allowHttp1 = false,
ServerSettings? settings}) {
return AngelHttp2._(app, (address, port) {
return ProtevusHttp2._(app, (address, port) {
var addr = address is InternetAddress
? address
: InternetAddress(address.toString());
@ -75,7 +75,7 @@ class AngelHttp2 extends Driver<Socket, ServerTransportStream,
@override
Future<SecureServerSocket> generateServer([address, int? port]) async {
var s = await serverGenerator(address ?? '127.0.0.1', port ?? 0);
return _artificial = _AngelHttp2ServerSocket(s, this);
return _artificial = _ProtevusHttp2ServerSocket(s, this);
}
@override
@ -158,13 +158,13 @@ class AngelHttp2 extends Driver<Socket, ServerTransportStream,
}
class _FakeServerSocket extends Stream<Socket> implements ServerSocket {
final _AngelHttp2ServerSocket angel;
final _ProtevusHttp2ServerSocket protevus;
final _ctrl = StreamController<Socket>();
_FakeServerSocket(this.angel);
_FakeServerSocket(this.protevus);
@override
InternetAddress get address => angel.address;
InternetAddress get address => protevus.address;
@override
Future<ServerSocket> close() async {
@ -173,7 +173,7 @@ class _FakeServerSocket extends Stream<Socket> implements ServerSocket {
}
@override
int get port => angel.port;
int get port => protevus.port;
@override
StreamSubscription<Socket> listen(void Function(Socket event)? onData,
@ -183,15 +183,15 @@ class _FakeServerSocket extends Stream<Socket> implements ServerSocket {
}
}
class _AngelHttp2ServerSocket extends Stream<SecureSocket>
class _ProtevusHttp2ServerSocket extends Stream<SecureSocket>
implements SecureServerSocket {
final SecureServerSocket socket;
final AngelHttp2 driver;
final ProtevusHttp2 driver;
final _ctrl = StreamController<SecureSocket>();
late _FakeServerSocket _fake;
StreamSubscription? _sub;
_AngelHttp2ServerSocket(this.socket, this.driver) {
_ProtevusHttp2ServerSocket(this.socket, this.driver) {
_fake = _FakeServerSocket(this);
HttpServer.listenOn(_fake).pipe(driver._onHttp1);
_sub = socket.listen(

View file

@ -31,7 +31,7 @@ class Http2RequestContext extends RequestContext<ServerTransportStream?> {
static Future<Http2RequestContext> from(
ServerTransportStream stream,
Socket socket,
Angel app,
Protevus app,
Map<String, MockHttpSession> sessions,
Uuid uuid) {
var c = Completer<Http2RequestContext>();

View file

@ -23,7 +23,7 @@ class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
Uri? _targetUri;
Http2ResponseContext(Angel? app, this.stream, this._req) {
Http2ResponseContext(Protevus? app, this.stream, this._req) {
this.app = app;
_targetUri = _req?.uri;
}

View file

@ -5,8 +5,8 @@ import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
void main() async {
var app = Angel();
var http = AngelHttp.custom(app, startShared, useZone: false);
var app = Protevus();
var http = ProtevusHttp.custom(app, startShared, useZone: false);
app.get('/', (req, res) => res.write('Hello, world!'));
app.optimizeForProduction(force: true);

View file

@ -2,7 +2,7 @@ name: angel3_framework
version: 8.4.0
description: A high-powered HTTP server extensible framework with dependency injection, routing and much more.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/framework
repository: https://github.com/dart-backend/protevus/tree/master/packages/framework
environment:
sdk: '>=3.3.0 <4.0.0'
dependencies:

View file

@ -64,7 +64,7 @@ Future<RequestContext> acceptContentTypes(
var rq = MockHttpRequest('GET', endpoint, persistentConnection: false);
rq.headers.set('accept', headerString);
rq.close();
var app = Angel(reflector: MirrorsReflector());
var http = AngelHttp(app);
var app = Protevus(reflector: MirrorsReflector());
var http = ProtevusHttp(app);
return http.createRequestContext(rq, rq.response);
}

View file

@ -23,21 +23,21 @@ void main() {
var svc = AnonymousService();
await svc.read(1);
throw 'Should have thrown 405!';
} on AngelHttpException {
} on ProtevusHttpException {
// print('Ok!');
}
try {
var svc = AnonymousService();
await svc.modify(2, null);
throw 'Should have thrown 405!';
} on AngelHttpException {
} on ProtevusHttpException {
// print('Ok!');
}
try {
var svc = AnonymousService();
await svc.update(3, null);
throw 'Should have thrown 405!';
} on AngelHttpException {
} on ProtevusHttpException {
// print('Ok!');
}
});

View file

@ -7,8 +7,8 @@ import 'package:angel3_mock_request/angel3_mock_request.dart';
import 'package:test/test.dart';
void main() {
var app = Angel();
var http = AngelHttp(app);
var app = Protevus();
var http = ProtevusHttp(app);
Future<RequestContext> request(
{bool asJson = true,

View file

@ -70,7 +70,7 @@ bool bar(RequestContext req, ResponseContext res) {
}
void main() {
late Angel app;
late Protevus app;
late TodoController todoController;
late NoExposeController noExposeCtrl;
late HttpServer server;
@ -78,7 +78,7 @@ void main() {
String? url;
setUp(() async {
app = Angel(reflector: MirrorsReflector());
app = Protevus(reflector: MirrorsReflector());
app.get(
'/redirect',
(req, res) async =>
@ -95,7 +95,7 @@ void main() {
noExposeCtrl = await app.mountController<NoExposeController>();
// Place controller in group. The applyRoutes() call, however, is async.
// Until https://github.com/angel-dart/route/issues/28 is closed,
// Until https://github.com/protevus-dart/route/issues/28 is closed,
// this will need to be done by manually mounting the router.
var subRouter = Router<RequestHandler>();
await todoController.applyRoutes(subRouter, app.container.reflector);
@ -104,7 +104,7 @@ void main() {
print(app.controllers);
app.dumpTree();
server = await AngelHttp(app).startServer();
server = await ProtevusHttp(app).startServer();
url = 'http://${server.address.address}:${server.port}';
});
@ -118,20 +118,20 @@ void main() {
});
test('create dynamic handler', () async {
var app = Angel(reflector: MirrorsReflector());
var app = Protevus(reflector: MirrorsReflector());
app.get(
'/foo',
ioc(({String? bar}) {
return 2;
}, optional: ['bar']));
var rq = MockHttpRequest('GET', Uri(path: 'foo'));
await AngelHttp(app).handleRequest(rq);
await ProtevusHttp(app).handleRequest(rq);
var body = await utf8.decoder.bind(rq.response).join();
expect(json.decode(body), 2);
});
test('optional name', () async {
var app = Angel(reflector: MirrorsReflector());
var app = Protevus(reflector: MirrorsReflector());
await app.configure(NamedController().configureServer);
expect(app.controllers['foo'], const IsInstanceOf<NamedController>());
});

View file

@ -5,11 +5,11 @@ import 'package:angel3_mock_request/angel3_mock_request.dart';
import 'package:test/test.dart';
void main() {
late AngelHttp http;
late ProtevusHttp http;
setUp(() async {
var app = Angel();
http = AngelHttp(app);
var app = Protevus();
http = ProtevusHttp(app);
app.get('/detach', (req, res) async {
if (res is HttpResponseContext) {

View file

@ -15,13 +15,13 @@ final String sampleText = 'make your bed';
final String sampleOver = 'never';
void main() {
late Angel app;
late Protevus app;
late http.Client client;
late HttpServer server;
String? url;
setUp(() async {
app = Angel(reflector: MirrorsReflector());
app = Protevus(reflector: MirrorsReflector());
client = http.Client();
// Inject some todos
@ -41,7 +41,7 @@ void main() {
await app.configure(SingletonController().configureServer);
await app.configure(ErrandController().configureServer);
server = await AngelHttp(app).startServer();
server = await ProtevusHttp(app).startServer();
url = 'http://${server.address.host}:${server.port}';
});
@ -52,7 +52,7 @@ void main() {
});
test('runContained with custom container', () async {
var app = Angel();
var app = Protevus();
var c = Container(const MirrorsReflector());
c.registerSingleton(Todo(text: 'Hey!'));
@ -63,7 +63,7 @@ void main() {
var rq = MockHttpRequest('GET', Uri(path: '/'));
await rq.close();
var rs = rq.response;
await AngelHttp(app).handleRequest(rq);
await ProtevusHttp(app).handleRequest(rq);
var text = await rs.transform(utf8.decoder).join();
expect(text, json.encode('Hey!'));
});

View file

@ -17,10 +17,10 @@ Future<List<int>> getBody(MockHttpResponse rs) async {
}
void main() {
late Angel app;
late Protevus app;
setUp(() {
app = Angel(reflector: MirrorsReflector());
app = Protevus(reflector: MirrorsReflector());
app.encoders.addAll(
{
'deflate': zlib.encoder,
@ -40,14 +40,14 @@ void main() {
encodingTests(() => app);
}
void encodingTests(Angel Function() getApp) {
void encodingTests(Protevus Function() getApp) {
group('encoding', () {
Angel app;
late AngelHttp http;
Protevus app;
late ProtevusHttp http;
setUp(() {
app = getApp();
http = AngelHttp(app);
http = ProtevusHttp(app);
});
test('sends plaintext if no accept-encoding', () async {

View file

@ -3,16 +3,17 @@ import 'package:angel3_framework/angel3_framework.dart';
import 'package:test/test.dart';
void main() {
test('custom value', () => expect(AngelEnvironment('hey').value, 'hey'));
test('custom value', () => expect(ProtevusEnvironment('hey').value, 'hey'));
test('lowercases', () => expect(AngelEnvironment('HeY').value, 'hey'));
test('lowercases', () => expect(ProtevusEnvironment('HeY').value, 'hey'));
test(
'default to env or development',
() => expect(AngelEnvironment().value,
() => expect(ProtevusEnvironment().value,
(Platform.environment['ANGEL_ENV'] ?? 'development').toLowerCase()));
test('isDevelopment',
() => expect(AngelEnvironment('development').isDevelopment, true));
test('isStaging', () => expect(AngelEnvironment('staging').isStaging, true));
() => expect(ProtevusEnvironment('development').isDevelopment, true));
test('isStaging',
() => expect(ProtevusEnvironment('staging').isStaging, true));
test('isDevelopment',
() => expect(AngelEnvironment('production').isProduction, true));
() => expect(ProtevusEnvironment('production').isProduction, true));
}

View file

@ -4,43 +4,46 @@ import 'package:test/test.dart';
void main() {
test('named constructors', () {
expect(
AngelHttpException.badRequest(), isException(400, '400 Bad Request'));
expect(AngelHttpException.notAuthenticated(),
expect(ProtevusHttpException.badRequest(),
isException(400, '400 Bad Request'));
expect(ProtevusHttpException.notAuthenticated(),
isException(401, '401 Not Authenticated'));
expect(AngelHttpException.paymentRequired(),
expect(ProtevusHttpException.paymentRequired(),
isException(402, '402 Payment Required'));
expect(AngelHttpException.forbidden(), isException(403, '403 Forbidden'));
expect(AngelHttpException.notFound(), isException(404, '404 Not Found'));
expect(AngelHttpException.methodNotAllowed(),
isException(405, '405 Method Not Allowed'));
expect(AngelHttpException.notAcceptable(),
isException(406, '406 Not Acceptable'));
expect(AngelHttpException.methodTimeout(), isException(408, '408 Timeout'));
expect(AngelHttpException.conflict(), isException(409, '409 Conflict'));
expect(AngelHttpException.notProcessable(),
isException(422, '422 Not Processable'));
expect(AngelHttpException.notImplemented(),
isException(501, '501 Not Implemented'));
expect(
AngelHttpException.unavailable(), isException(503, '503 Unavailable'));
ProtevusHttpException.forbidden(), isException(403, '403 Forbidden'));
expect(ProtevusHttpException.notFound(), isException(404, '404 Not Found'));
expect(ProtevusHttpException.methodNotAllowed(),
isException(405, '405 Method Not Allowed'));
expect(ProtevusHttpException.notAcceptable(),
isException(406, '406 Not Acceptable'));
expect(
ProtevusHttpException.methodTimeout(), isException(408, '408 Timeout'));
expect(ProtevusHttpException.conflict(), isException(409, '409 Conflict'));
expect(ProtevusHttpException.notProcessable(),
isException(422, '422 Not Processable'));
expect(ProtevusHttpException.notImplemented(),
isException(501, '501 Not Implemented'));
expect(ProtevusHttpException.unavailable(),
isException(503, '503 Unavailable'));
});
test('fromMap', () {
expect(AngelHttpException.fromMap({'status_code': -1, 'message': 'ok'}),
expect(ProtevusHttpException.fromMap({'status_code': -1, 'message': 'ok'}),
isException(-1, 'ok'));
});
test('toMap = toJson', () {
var exc = AngelHttpException.badRequest();
var exc = ProtevusHttpException.badRequest();
expect(exc.toMap(), exc.toJson());
var json_ = json.encode(exc.toJson());
var exc2 = AngelHttpException.fromJson(json_);
var exc2 = ProtevusHttpException.fromJson(json_);
expect(exc2.toJson(), exc.toJson());
});
test('toString', () {
expect(AngelHttpException(statusCode: 420, message: 'Blaze It').toString(),
expect(
ProtevusHttpException(statusCode: 420, message: 'Blaze It').toString(),
'420: Blaze It');
});
}
@ -60,7 +63,7 @@ class _IsException extends Matcher {
@override
bool matches(item, Map matchState) {
return item is AngelHttpException &&
return item is ProtevusHttpException &&
item.statusCode == statusCode &&
item.message == message;
}

View file

@ -26,7 +26,7 @@ void main() {
Future<RequestContext> makeRequest(String path) {
var rq = MockHttpRequest('GET', endpoint.replace(path: path))..close();
var app = Angel(reflector: MirrorsReflector());
var http = AngelHttp(app);
var app = Protevus(reflector: MirrorsReflector());
var http = ProtevusHttp(app);
return http.createRequestContext(rq, rq.response);
}

View file

@ -4,7 +4,7 @@ import 'common.dart';
void main() {
var throwsAnAngelHttpException =
throwsA(const IsInstanceOf<AngelHttpException>());
throwsA(const IsInstanceOf<ProtevusHttpException>());
/*
test('throw 404 on null', () {

View file

@ -7,18 +7,18 @@ import 'package:http/http.dart' as http;
import 'package:test/test.dart';
void main() {
late Angel app;
late Protevus app;
late http.Client client;
late HttpServer server;
late String url;
setUp(() async {
app = Angel(reflector: MirrorsReflector())
app = Protevus(reflector: MirrorsReflector())
..post('/foo', (req, res) => res.serialize({'hello': 'world'}))
..all('*', (req, res) => throw AngelHttpException.notFound());
..all('*', (req, res) => throw ProtevusHttpException.notFound());
client = http.Client();
server = await AngelHttp(app).startServer();
server = await ProtevusHttp(app).startServer();
url = 'http://${server.address.host}:${server.port}';
});

View file

@ -13,14 +13,14 @@ void main() {
'Content-Type': 'application/json'
};
late Angel app;
late Protevus app;
late HttpServer server;
late String url;
late http.Client client;
late HookedService todoService;
setUp(() async {
app = Angel(reflector: MirrorsReflector());
app = Protevus(reflector: MirrorsReflector());
client = http.Client();
app.use('/todos', MapService());
app.use('/books', BookService());
@ -36,7 +36,7 @@ void main() {
throw e.error as Object;
};
server = await AngelHttp(app).startServer();
server = await ProtevusHttp(app).startServer();
url = 'http://${server.address.host}:${server.port}';
});
@ -83,7 +83,7 @@ void main() {
..listen((HookedServiceEvent event) async {
// Hooks can be Futures ;)
event.cancel([
{'angel': 'framework'}
{'protevus': 'framework'}
]);
})
..listen((HookedServiceEvent event) {
@ -93,13 +93,13 @@ void main() {
var response = await client.get(Uri.parse('$url/todos'));
print(response.body);
var result = json.decode(response.body) as List;
expect(result[0]['angel'], equals('framework'));
expect(result[0]['protevus'], equals('framework'));
});
test('asStream() fires', () async {
var stream = todoService.afterCreated.asStream();
await todoService.create({'angel': 'framework'});
expect(await stream.first.then((e) => e.result['angel']), 'framework');
await todoService.create({'protevus': 'framework'});
expect(await stream.first.then((e) => e.result['protevus']), 'framework');
});
test('metadata', () async {

View file

@ -25,14 +25,15 @@ Stream<List<int>> jfkStream() {
void main() {
var client = Http2Client();
late IOClient h1c;
Angel app;
late AngelHttp2 http2;
Protevus app;
late ProtevusHttp2 http2;
late Uri serverRoot;
setUp(() async {
app = Angel(reflector: MirrorsReflector())..encoders['gzip'] = gzip.encoder;
app = Protevus(reflector: MirrorsReflector())
..encoders['gzip'] = gzip.encoder;
hierarchicalLoggingEnabled = true;
app.logger = Logger.detached('angel.http2')
app.logger = Logger.detached('protevus.http2')
..onRecord.listen((rec) {
print(rec);
if (rec.error == null) return;
@ -52,7 +53,7 @@ void main() {
app.get('/stream', (req, res) => jfkStream().pipe(res));
app.get('/headers', (req, res) async {
res.headers.addAll({'foo': 'bar', 'x-angel': 'http2'});
res.headers.addAll({'foo': 'bar', 'x-protevus': 'http2'});
await res.close();
});
@ -105,7 +106,7 @@ void main() {
// Create an HTTP client that trusts our server.
h1c = IOClient(HttpClient()..badCertificateCallback = (_, __, ___) => true);
http2 = AngelHttp2(app, ctx, allowHttp1: true);
http2 = ProtevusHttp2(app, ctx, allowHttp1: true);
var server = await http2.startServer();
serverRoot = Uri.parse('https://127.0.0.1:${server.port}');
@ -183,7 +184,7 @@ void main() {
test('headers sent', () async {
var response = await client.get(serverRoot.replace(path: '/headers'));
expect(response.headers['foo'], 'bar');
expect(response.headers['x-angel'], 'http2');
expect(response.headers['x-protevus'], 'http2');
});
test('server push', () async {
@ -287,7 +288,7 @@ void main() {
rq.fields['foo'] = 'bar';
rq.files.add(http.MultipartFile(
'file', Stream.fromIterable([utf8.encode('hello world')]), 11,
contentType: MediaType('angel', 'framework')));
contentType: MediaType('protevus', 'framework')));
var response = await client.send(rq);
var responseBody = await response.stream.transform(utf8.decoder).join();
@ -296,7 +297,7 @@ void main() {
responseBody,
json.encode([
11,
'angel/framework',
'protevus/framework',
{'foo': 'bar'}
]));
});

View file

@ -9,7 +9,7 @@ import 'pretty_log.dart';
void main() {
late http.IOClient client;
late AngelHttp driver;
late ProtevusHttp driver;
late Logger logger;
setUp(() async {
@ -20,7 +20,7 @@ void main() {
..level = Level.ALL
..onRecord.listen(prettyLog);
var app = Angel(logger: logger);
var app = Protevus(logger: logger);
app.fallback(hello);
app.fallback(throw404);
@ -40,7 +40,7 @@ void main() {
}
};
driver = AngelHttp(app);
driver = ProtevusHttp(app);
await driver.startServer();
});
@ -76,5 +76,5 @@ Future<void> hello(RequestContext req, ResponseContext res) {
void throw404(RequestContext req, ResponseContext res) {
Zone.current
.handleUncaughtError('This 404 should not occur.', StackTrace.current);
throw AngelHttpException.notFound();
throw ProtevusHttpException.notFound();
}

Some files were not shown because too many files have changed in this diff Show more