Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

1.0 #152

Merged
merged 36 commits into from
Dec 7, 2016
Merged

1.0 #152

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bfe5a3d
Fixing contentType behavior for Response
itsjoeconway Nov 16, 2016
e8b8148
Fix tests to use content-type
itsjoeconway Nov 19, 2016
7c67f07
Changing behavior for content type interpretation/handling for Response
itsjoeconway Nov 19, 2016
3411ee7
Fixed documentation
itsjoeconway Nov 19, 2016
3960853
Fixed docs, fixed style thing
itsjoeconway Nov 19, 2016
46948eb
dartfmt
itsjoeconway Nov 22, 2016
f839466
Bump version number, change log
itsjoeconway Nov 22, 2016
8f86c7c
WIP; clean up private/public
itsjoeconway Nov 23, 2016
4948854
Updated test/template projects to use import instead of part, changed…
itsjoeconway Nov 28, 2016
ee8a7e8
Cleaning up template project
itsjoeconway Nov 28, 2016
461f99c
Cleaned up API a bit, hid some things
itsjoeconway Nov 28, 2016
2c3966a
Moved isolate exception back to public to prevent from breaking exist…
itsjoeconway Nov 28, 2016
13bd5e2
dartfmt
itsjoeconway Nov 28, 2016
17fa85b
Fixed type on app config
itsjoeconway Nov 29, 2016
0590b99
Update CHANGELOG.md
itsjoeconway Nov 30, 2016
c907b5f
Fixed bug with isNotPresent in partial matcher. (#143)
anachlas Nov 30, 2016
8c9bef9
Cleaned up example requestsink a smidgen
itsjoeconway Nov 29, 2016
fa39ce3
Revert "Cleaned up example requestsink a smidgen"
itsjoeconway Nov 29, 2016
698d4b6
Fixing small thing in template sink
itsjoeconway Nov 29, 2016
e632827
Renaming some things
itsjoeconway Nov 29, 2016
5834dfd
Made a few static values const
itsjoeconway Nov 29, 2016
a786be7
Fixing up some tests, test_all generator
itsjoeconway Nov 30, 2016
872c4e5
Updated some tests, made the last managedcontext the default context
itsjoeconway Nov 30, 2016
cb7dce0
Removed unused method
itsjoeconway Nov 30, 2016
fc32de3
Added instructions for running tests and collecting coverage
itsjoeconway Nov 30, 2016
0b75d3f
UPdated change log
itsjoeconway Nov 30, 2016
d5ca1f0
Using codecov and adding to travis
itsjoeconway Nov 30, 2016
5101d6e
pr feedback
itsjoeconway Dec 1, 2016
86deab9
Jc/fix managed resolution (#147)
itsjoeconway Dec 4, 2016
54aec02
Jc/explicit query values (#148)
itsjoeconway Dec 6, 2016
1bc0f7e
Fixing some naming and ordering in template (#150)
itsjoeconway Dec 7, 2016
9dde4e9
Getting code coverage to only run on master (#151)
itsjoeconway Dec 7, 2016
8ab4bf2
Updating after_script
itsjoeconway Dec 7, 2016
e851295
Changing script error
itsjoeconway Dec 7, 2016
dae0089
Debugging travis script
itsjoeconway Dec 7, 2016
5e3cbf9
Getting reason why tests fail in code cov env, removing debug code fr…
itsjoeconway Dec 7, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .analysis_options
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
analyzer:
strong-mode: true
strong-mode: true
exclude:
- tmp_templates/**
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ before_script:
- psql -c "alter user dart with password 'dart';" -U postgres
- psql -c 'grant all on database dart_test to dart;' -U postgres
- pub get
script: pub run test -j 1 -r expanded
script: bash ci/script.sh
after_success: bash ci/after_script.sh
branches:
only:
- master
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# aqueduct changelog

## 1.0.4
- BREAKING CHANGE: Added new `Response.contentType` property. Adding "Content-Type" to the headers of a `Response` no longer has any effect; use this property instead.
- `ManagedDataModel`s now scan all libraries for `ManagedObject<T>` subclasses to generate a data model. Use `ManagedDataModel.fromCurrentMirrorSystem` to create instances of `ManagedDataModel`.
- The *last* instantiated `ManagedContext` now becomes the `ManagedContext.defaultContext`; prior to this change, it was the first instantiated context. Added `ManagedContext.standalone` to opt out of setting the default context.
- @HTTPQuery parameters in HTTPController responder method will now only allow multiple keys in the query string if and only if the argument type is a List.

## 1.0.3
- Fix to allow Windows user to use `aqueduct setup`.
- Fix to CORS processing.
Expand Down
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Running Tests

A local database must exist, configured using the same script in .travis.yml.

Tests are run with the following command:

pub run test -j 1
21 changes: 13 additions & 8 deletions bin/aqueduct.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'dart:async';
import 'package:args/args.dart';
import 'dart:io';

import 'package:aqueduct/aqueduct.dart';
import 'package:args/args.dart';

Future<int> main(List<String> args) async {
main(List<String> args) async {
var templateCreator = new CLITemplateCreator();
var migrationRunner = new CLIMigrationRunner();
var setupCommand = new CLISetup();
Expand All @@ -19,16 +20,20 @@ Future<int> main(List<String> args) async {
if (values.command == null) {
print(
"Invalid command, options are: ${totalParser.commands.keys.join(", ")}");
return -1;
exitCode = 1;
return;
} else if (values.command.name == "create") {
return await templateCreator.process(values.command);
exitCode = await templateCreator.process(values.command);
return;
} else if (values.command.name == "db") {
return await migrationRunner.process(values.command);
exitCode = await migrationRunner.process(values.command);
return;
} else if (values.command.name == "setup") {
return await setupCommand.process(values.command);
exitCode = await setupCommand.process(values.command);
return;
}

print(
"Invalid command, options are: ${totalParser.commands.keys.join(", ")}");
return -1;
exitCode = 1;
}
7 changes: 7 additions & 0 deletions ci/after_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [[ "$TRAVIS_BRANCH" == "master" ]]; then
curl -s https://codecov.io/bash > .codecov
chmod +x .codecov
./.codecov -f lcov.info -X xcode
fi
7 changes: 7 additions & 0 deletions ci/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

pub run test -j 1 -r expanded
if [[ "$TRAVIS_BRANCH" == "master" ]]; then
pub global activate -sgit https://github.com/stablekernel/codecov_dart.git
dart_codecov_generator --report-on=lib/ --verbose --no-html
fi
3 changes: 0 additions & 3 deletions example/templates/default/bin/start.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ main() async {

var signalPath = new File(".aqueductsignal");
await signalPath.writeAsString("ok");
} on ApplicationSupervisorException catch (e, st) {
await writeError(
"IsolateSupervisorException, server failed to start: ${e.message} $st");
} catch (e, st) {
await writeError("Server failed to start: $e $st");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of wildfire;
import '../wildfire.dart';

class IdentityController extends HTTPController {
@httpGet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
part of wildfire;
import '../wildfire.dart';

class RegisterController extends QueryController<User> {
@httpPost
createUser() async {
if (query.values.username == null || query.values.password == null) {
if (query.values.email == null || query.values.password == null) {
return new Response.badRequest(
body: {"error": "Username and password required."});
body: {"error": "email and password required."});
}
var credentials = AuthorizationBasicParser
.parse(request.innerRequest.headers.value(HttpHeaders.AUTHORIZATION));

var salt = AuthServer.generateRandomSalt();
var hashedPassword =
Expand All @@ -15,9 +17,6 @@ class RegisterController extends QueryController<User> {
query.values.salt = salt;

var u = await query.insert();

var credentials = AuthorizationBasicParser
.parse(request.innerRequest.headers.value(HttpHeaders.AUTHORIZATION));
var token = await request.authorization.grantingServer.authenticate(
u.username,
query.values.password,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of wildfire;
import '../wildfire.dart';

class UserController extends QueryController<User> {
@httpGet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of wildfire;
import '../wildfire.dart';

class AuthCode extends ManagedObject<_AuthCode> implements _AuthCode {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of wildfire;
import '../wildfire.dart';

class User extends ManagedObject<_User> implements _User, Authenticatable {
@managedTransientInputAttribute
Expand Down
84 changes: 0 additions & 84 deletions example/templates/default/lib/src/wildfire_sink.dart

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
part of wildfire;
import '../wildfire.dart';

class WildfireAuthenticationDelegate
class WildfireAuthDelegate
implements AuthServerDelegate<User, Token, AuthCode> {
Future<AuthClient> clientForID(AuthServer server, String id) async {
var clientQ = new Query<ClientRecord>()..matchOn.id = id;
Expand Down
21 changes: 10 additions & 11 deletions example/templates/default/lib/wildfire.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
/// A web server.
library wildfire;

import 'dart:io';
import 'dart:async';
import 'package:aqueduct/aqueduct.dart';
import 'package:scribe/scribe.dart';
export 'dart:async';
export 'dart:io';

export 'package:aqueduct/aqueduct.dart';
export 'package:scribe/scribe.dart';

part 'src/model/token.dart';
part 'src/model/user.dart';
part 'src/wildfire_sink.dart';
part 'src/controller/user_controller.dart';
part 'src/controller/identity_controller.dart';
part 'src/controller/register_controller.dart';
part 'src/utilities/auth_delegate.dart';
export 'wildfire_sink.dart';
export 'model/token.dart';
export 'model/user.dart';
export 'controller/user_controller.dart';
export 'controller/identity_controller.dart';
export 'controller/register_controller.dart';
export 'utilities/auth_delegate.dart';

104 changes: 104 additions & 0 deletions example/templates/default/lib/wildfire_sink.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import 'wildfire.dart';

/// This class handles setting up this application.
///
/// Override methods from [RequestSink] to set up the resources your
/// application uses and the routes it exposes.
///
/// Instances of this class are the type argument to [Application].
/// See http://stablekernel.github.io/aqueduct/http/request_sink.html
/// for more details.
///
/// See bin/start.dart for usage.
class WildfireSink extends RequestSink {
static const String ConfigurationKey = "ConfigurationKey";
static const String LoggingTargetKey = "LoggingTargetKey";

/// [Application] creates instances of this type with this constructor.
///
/// The options will be the values set in the spawning [Application]'s
/// [Application.configuration] [ApplicationConfiguration.configurationOptions].
/// See bin/start.dart.
WildfireSink(Map<String, dynamic> opts) : super(opts) {
WildfireConfiguration configuration = opts[ConfigurationKey];

LoggingTarget target = opts[LoggingTargetKey];
target?.bind(logger);

context = contextWithConnectionInfo(configuration.database);

authServer = new AuthServer<User, Token, AuthCode>(
new WildfireAuthDelegate());
}

ManagedContext context;
AuthServer<User, Token, AuthCode> authServer;

/// All routes must be configured in this method.
@override
void setupRouter(Router router) {
router
.route("/auth/token")
.pipe(
new Authorizer(authServer, strategy: AuthStrategy.client))
.generate(() => new AuthController(authServer));

router
.route("/auth/code")
.pipe(
new Authorizer(authServer, strategy: AuthStrategy.client))
.generate(() => new AuthCodeController(authServer));

router
.route("/identity")
.pipe(new Authorizer(authServer))
.generate(() => new IdentityController());

router
.route("/register")
.pipe(
new Authorizer(authServer, strategy: AuthStrategy.client))
.generate(() => new RegisterController());

router
.route("/users/[:id]")
.pipe(new Authorizer(authServer))
.generate(() => new UserController());
}

ManagedContext contextWithConnectionInfo(
DatabaseConnectionConfiguration connectionInfo) {
var dataModel =
new ManagedDataModel.fromCurrentMirrorSystem();
var psc = new PostgreSQLPersistentStore.fromConnectionInfo(
connectionInfo.username,
connectionInfo.password,
connectionInfo.host,
connectionInfo.port,
connectionInfo.databaseName);

var ctx = new ManagedContext(dataModel, psc);
ManagedContext.defaultContext = ctx;

return ctx;
}

@override
Map<String, APISecurityScheme> documentSecuritySchemes(
PackagePathResolver resolver) {
return authServer.documentSecuritySchemes(resolver);
}
}

/// An instance of this class represents values from a configuration
/// file specific to this application.
///
/// Configuration files must have key-value for the properties in this class.
/// For more documentation on configuration files, see
/// https://pub.dartlang.org/packages/safe_config.
class WildfireConfiguration extends ConfigurationItem {
WildfireConfiguration(String fileName) : super.fromFile(fileName);

DatabaseConnectionConfiguration database;
int port;
}
Loading