Skip to content

Commit

Permalink
Merge pull request #30 from tejainece/master
Browse files Browse the repository at this point in the history
Param and state injection
  • Loading branch information
Kleak authored Nov 8, 2016
2 parents 8af6bf4 + 39937f0 commit add249c
Show file tree
Hide file tree
Showing 31 changed files with 454 additions and 339 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ Jaguar, a server framework built for **speed, simplicity and extensiblity**.
1. Keeps your route handlers concise and clean
2. Bare metal speed achieved through code generation
3. Extensible interceptor infrastructure
4. Generates API console client to try your server without writing single line of
client code
5. Mock HTTP requests and use dependency injection to test your API
4. Generates API console client to try your server without writing single
line of client code
5. Tests are first class citizens in jaguar
i. Mock HTTP requests and Websocket requests
ii. Use dependency injection to test your API
6. Optional Firebase/Parse like no code or little code servers

Even though Jaguar is feature rich, it is simpler and easy to get started.
Expand Down
4 changes: 2 additions & 2 deletions example/forum/forum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class ForumApi extends Object with _$JaguarForumApi {
methods: const <String>['GET'],
statusCode: 201,
headers: const {"sample-header": "made-with.jaguar"})
@MongoDb('test', id: 'Test')
@MongoDb('test', id: 'Test', state: const MongoDbState())
@MongoDb('admin', id: 'Admin')
@Login()
@Login(const LoginState())
@EncodeToJson()
Future<User> fetch() async {
return new User('[email protected]', 'Dummy', 'password', 27);
Expand Down
33 changes: 23 additions & 10 deletions example/forum/forum.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 20 additions & 2 deletions example/forum/interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,21 @@ class User implements ViewSerializer, ModelSerializer {
Map toModelMap() => toMap()..['pwdH'] = passwordHash;
}

class MongoDbState {
final String whatever;

const MongoDbState({this.whatever});
}

@InterceptorClass()
class MongoDb extends Interceptor {
final String dbName;

const MongoDb(this.dbName, {String id}) : super(id: id);
final MongoDbState state;

const MongoDb(this.dbName, {String id, this.state}) : super(id: id);

static MongoDbState createState() => new MongoDbState();

Future<Db> pre() async {
return new Db();
Expand All @@ -70,9 +80,17 @@ class MongoDb extends Interceptor {
Future post() async {}
}

class LoginState {
final String whatever;

const LoginState({this.whatever});
}

@InterceptorClass()
class Login extends Interceptor {
const Login();
final LoginState state;

const Login([this.state]);

@Input(MongoDb, id: 'Admin')
void pre(Db db) {}
Expand Down
3 changes: 1 addition & 2 deletions example/silly/main.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions jaguar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ apis:
- 'test/jaguar/route/route.dart'
- 'test/jaguar/group/main.dart'
- 'test/jaguar/websocket/websocket.dart'
- 'test/interceptor/param/param.dart'
216 changes: 0 additions & 216 deletions lib/generator/internal/element/import.dart

This file was deleted.

Loading

0 comments on commit add249c

Please sign in to comment.