diff --git a/.gitignore b/.gitignore index 74215e2a..678efe20 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ .metals/ build/ #**/packages/ -packages/hubbub/ # Files created by dart2js # (Most Dart developers will use pub build to compile Dart, use/modify these diff --git a/packages/auth/pubspec.yaml b/packages/auth/pubspec.yaml index cf5c8f65..4a761a56 100644 --- a/packages/auth/pubspec.yaml +++ b/packages/auth/pubspec.yaml @@ -2,7 +2,6 @@ name: angel3_auth description: A complete authentication plugin for Angel. Includes support for stateless JWT tokens, Basic Auth, and more. version: 4.0.4 homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/auth -#publish_to: none environment: sdk: '>=2.12.0 <3.0.0' dependencies: diff --git a/packages/auth_twitter/example/main.dart b/packages/auth_twitter/example/main.dart index 64f23d53..d7e586b3 100644 --- a/packages/auth_twitter/example/main.dart +++ b/packages/auth_twitter/example/main.dart @@ -14,7 +14,7 @@ class _User { Map toJson() => {'handle': handle}; } -main() async { +void main() async { var app = Angel(); var http = AngelHttp(app); var auth = AngelAuth<_User>( @@ -48,7 +48,7 @@ main() async { if (e.isDenial) { res.write("Why'd you say no???"); } else { - res.write("oops: ${e.message}"); + res.write('oops: ${e.message}'); } }, ); @@ -57,18 +57,17 @@ main() async { ..fallback(auth.decodeJwt) ..get('/', auth.authenticate('twitter')); - app - ..get( - '/auth/twitter/callback', - auth.authenticate( - 'twitter', - AngelAuthOptions( - callback: (req, res, jwt) { - return res.redirect('/home?token=$jwt'); - }, - ), + app.get( + '/auth/twitter/callback', + auth.authenticate( + 'twitter', + AngelAuthOptions( + callback: (req, res, jwt) { + return res.redirect('/home?token=$jwt'); + }, ), - ); + ), + ); app.get( '/home', diff --git a/packages/auth_twitter/lib/angel_auth_twitter.dart b/packages/auth_twitter/lib/angel_auth_twitter.dart index ccda7fe3..e60d5fdb 100644 --- a/packages/auth_twitter/lib/angel_auth_twitter.dart +++ b/packages/auth_twitter/lib/angel_auth_twitter.dart @@ -32,7 +32,7 @@ class TwitterStrategy extends AuthStrategy { TwitterStrategy(this.options, this.verifier, this.onError, {http.BaseClient client, Uri baseUrl}) - : this.baseUrl = baseUrl ?? Uri.parse('https://api.twitter.com') { + : baseUrl = baseUrl ?? Uri.parse('https://api.twitter.com') { var tokens = oauth.Tokens( consumerId: options.clientId, consumerKey: options.clientSecret); _client = oauth.Client(tokens, client: client); diff --git a/packages/body_parser/README.md b/packages/body_parser/README.md index 6c577eab..918312f4 100644 --- a/packages/body_parser/README.md +++ b/packages/body_parser/README.md @@ -1,14 +1,15 @@ -# body_parser -[![Pub](https://img.shields.io/pub/v/body_parser.svg)](https://pub.dartlang.org/packages/body_parser) -[![build status](https://travis-ci.org/angel-dart/body_parser.svg)](https://travis-ci.org/angel-dart/body_parser) +# Angel3 Body Parser +[![version](https://img.shields.io/badge/pub-v2.0.0-brightgreen)](https://pub.dartlang.org/packages/angel3_body_parser) +[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) +[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) -Parse request bodies and query strings in Dart, as well multipart/form-data uploads. No external -dependencies required. +[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/body_parser/LICENSE) -This is the request body parser powering the -[Angel](https://angel-dart.github.io) -framework. If you are looking for a server-side solution with dependency injection, -WebSockets, and more, then I highly recommend it as your first choice. Bam! +**Forked from `body_parser` to support NNBD** + +Parse request bodies and query strings in Dart, as well multipart/form-data uploads. No external dependencies required. + +This is the request body parser powering the [Angel3](https://github.com/dukefirehawk/angel) framework. If you are looking for a server-side solution with dependency injection, WebSockets, and more, then I highly recommend it as your first choice. Bam! ### Contents @@ -33,7 +34,7 @@ To install Body Parser for your Dart project, simply add body_parser to your pub dependencies. dependencies: - body_parser: any + angel3_body_parser: ^2.0.0 # Usage @@ -42,7 +43,7 @@ You can easily parse the query string and request body for a request by calling ```dart import 'dart:convert'; -import 'package:body_parser/body_parser.dart'; +import 'package:angel3_body_parser/angel3_body_parser.dart'; main() async { // ... @@ -55,8 +56,7 @@ main() async { You can also use `buildMapFromUri(Map, String)` to populate a map from a URL encoded string. -This can easily be used with a library like [JSON God](https://github.com/thosakwe/json_god) -to build structured JSON/REST APIs. Add validation and you've got an instant backend. +This can easily be used with a library like [Angel3 JSON God](https://pub.dev/packages/angel3_json_god) to build structured JSON/REST APIs. Add validation and you've got an instant backend. ```dart MyClass create(HttpRequest request) async { @@ -69,13 +69,12 @@ In cases where you need to parse unrecognized content types, `body_parser` won't on its own. However, you can use the `originalBuffer` property of a `BodyParseResult` to see the original request buffer. To get this functionality, pass `storeOriginalBuffer` as `true` when calling `parseBody`. -For example, if you wanted to -[parse GraphQL queries within your server](https://github.com/angel-dart/graphql)... +For example, if you wanted to [parse GraphQL queries within your server](https://github.com/dukefirehawk/graphql_dart)... ```dart app.get('/graphql', (req, res) async { if (req.headers.contentType.mimeType == 'application/graphql') { - var graphQlString = new String.fromCharCodes(req.originalBuffer); + var graphQlString = String.fromCharCodes(req.originalBuffer); // ... } }); diff --git a/packages/body_parser/example/main.dart b/packages/body_parser/example/main.dart index b882307b..62eb3f30 100644 --- a/packages/body_parser/example/main.dart +++ b/packages/body_parser/example/main.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'dart:io'; import 'dart:isolate'; import 'package:http_parser/http_parser.dart'; -import 'package:body_parser/body_parser.dart'; +import 'package:angel3_body_parser/angel3_body_parser.dart'; void main() async { var address = '127.0.0.1'; diff --git a/packages/body_parser/lib/body_parser.dart b/packages/body_parser/lib/angel3_body_parser.dart similarity index 85% rename from packages/body_parser/lib/body_parser.dart rename to packages/body_parser/lib/angel3_body_parser.dart index 0541b3e6..05a163e5 100644 --- a/packages/body_parser/lib/body_parser.dart +++ b/packages/body_parser/lib/angel3_body_parser.dart @@ -1,5 +1,5 @@ /// A library for parsing HTTP request bodies and queries. -library body_parser; +library angel3_body_parser; export 'src/body_parse_result.dart'; export 'src/file_upload_info.dart'; diff --git a/packages/body_parser/pubspec.yaml b/packages/body_parser/pubspec.yaml index 1f5b5b8c..04448052 100644 --- a/packages/body_parser/pubspec.yaml +++ b/packages/body_parser/pubspec.yaml @@ -1,7 +1,7 @@ -name: body_parser +name: angel3_body_parser version: 2.0.0 description: Parse request bodies and query strings in Dart. Supports JSON, URL-encoded, and multi-part bodies. -homepage: https://github.com/angel-dart/body_parser +homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/body_parser environment: sdk: '>=2.12.0 <3.0.0' dependencies: diff --git a/packages/body_parser/test/form_data_test.dart b/packages/body_parser/test/form_data_test.dart index dfa27a28..f9624390 100644 --- a/packages/body_parser/test/form_data_test.dart +++ b/packages/body_parser/test/form_data_test.dart @@ -1,6 +1,6 @@ import 'dart:io'; import 'dart:convert'; -import 'package:body_parser/body_parser.dart'; +import 'package:angel3_body_parser/angel3_body_parser.dart'; import 'package:http/http.dart' as http; import 'package:test/test.dart'; import 'server_test.dart'; diff --git a/packages/body_parser/test/server_test.dart b/packages/body_parser/test/server_test.dart index 5ca2a8da..7a8b61a0 100644 --- a/packages/body_parser/test/server_test.dart +++ b/packages/body_parser/test/server_test.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'dart:io' show HttpRequest, HttpServer; -import 'package:body_parser/body_parser.dart'; +import 'package:angel3_body_parser/angel3_body_parser.dart'; import 'package:http/http.dart' as http; import 'package:test/test.dart'; @@ -93,8 +93,8 @@ void main() { }; test('POST Simple', () async { print('Body: hello=world'); - var response = await client!.post(Uri.parse(url!), - headers: headers, body: 'hello=world'); + var response = await client! + .post(Uri.parse(url!), headers: headers, body: 'hello=world'); print('Response: ${response.body}'); var result = json.decode(response.body); expect(result['query'], equals({})); diff --git a/packages/cache/lib/src/serializer.dart b/packages/cache/lib/src/serializer.dart index 0c74fc14..8fc68270 100644 --- a/packages/cache/lib/src/serializer.dart +++ b/packages/cache/lib/src/serializer.dart @@ -20,7 +20,7 @@ RequestHandler cacheSerializationResults( // return cache.putIfAbsent(value, () => oldSerializer(value)); //} - return oldSerializer!(value); + return oldSerializer(value); }; return true; diff --git a/packages/shelf/pubspec.yaml b/packages/shelf/pubspec.yaml index f0b75496..da49c091 100644 --- a/packages/shelf/pubspec.yaml +++ b/packages/shelf/pubspec.yaml @@ -4,7 +4,7 @@ description: Shelf interop with Angel. Use this to wrap existing server code. homepage: https://github.com/angel-dart/shelf publish_to: none environment: - sdk: '>=2.10.0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dependencies: angel_framework: git: