Added validation, Grinder
This commit is contained in:
parent
0efff900bc
commit
adbd59c5ee
4 changed files with 34 additions and 13 deletions
|
@ -1 +0,0 @@
|
||||||
const Map UserSchema = const {};
|
|
|
@ -1,11 +1,9 @@
|
||||||
import 'package:angel_framework/angel_framework.dart';
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
import 'package:angel_mongo/angel_mongo.dart';
|
import 'package:angel_mongo/angel_mongo.dart';
|
||||||
import 'package:crypto/crypto.dart' show sha256;
|
import 'package:crypto/crypto.dart' show sha256;
|
||||||
import 'package:json_god/json_god.dart' as god;
|
|
||||||
import 'package:mongo_dart/mongo_dart.dart';
|
import 'package:mongo_dart/mongo_dart.dart';
|
||||||
import 'schema.dart';
|
import 'package:validate/validate.dart';
|
||||||
|
|
||||||
@god.WithSchema(UserSchema)
|
|
||||||
class User extends Model {
|
class User extends Model {
|
||||||
String email;
|
String email;
|
||||||
String username;
|
String username;
|
||||||
|
@ -35,6 +33,13 @@ configureServer(Db db) {
|
||||||
HookedService service = app.service("api/users");
|
HookedService service = app.service("api/users");
|
||||||
|
|
||||||
// Place your hooks here!
|
// Place your hooks here!
|
||||||
|
|
||||||
|
service.beforeCreated.listen((HookedServiceEvent e) {
|
||||||
|
Validate.isKeyInMap("username", e.data);
|
||||||
|
Validate.isEmail(e.data["email"]);
|
||||||
|
Validate.isPassword(e.data["password"]);
|
||||||
|
});
|
||||||
|
|
||||||
service.beforeCreated.listen(hashPassword);
|
service.beforeCreated.listen(hashPassword);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
20
pubspec.yaml
20
pubspec.yaml
|
@ -5,13 +5,15 @@ author: thosakwe <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/angel
|
homepage: https://github.com/angel-dart/angel
|
||||||
publish_to: none
|
publish_to: none
|
||||||
dependencies:
|
dependencies:
|
||||||
angel_auth: ">=1.0.0-dev <2.0.0"
|
angel_auth: ^1.0.0-dev
|
||||||
angel_configuration: ">=1.0.0-dev <2.0.0"
|
angel_configuration: ^1.0.0-dev
|
||||||
angel_framework: ">=1.0.0-dev <2.0.0"
|
angel_framework: ^1.0.0-dev
|
||||||
angel_mongo: ">=1.0.0-dev <2.0.0"
|
angel_mongo: ^1.0.0-dev
|
||||||
angel_mustache: ">=1.0.0-dev <2.0.0"
|
angel_mustache: ^1.0.0-dev
|
||||||
angel_static: ">=1.0.0 <1.1.0"
|
angel_static: ^1.0.0
|
||||||
json_god: ">=2.0.0-beta <3.0.0"
|
json_god: ^2.0.0-beta
|
||||||
|
validate: ^1.5.2
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
http: ">=0.11.3 <0.12.0"
|
http: ^0.11.3
|
||||||
test: ">=0.12.13 <0.13.0"
|
grinder: ^0.8.0+2
|
||||||
|
test: ^0.12.13
|
15
tool/grind.dart
Normal file
15
tool/grind.dart
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import 'package:grinder/grinder.dart';
|
||||||
|
|
||||||
|
main(args) => grind(args);
|
||||||
|
|
||||||
|
@Task()
|
||||||
|
test() => new TestRunner().testAsync();
|
||||||
|
|
||||||
|
@DefaultTask()
|
||||||
|
@Depends(test)
|
||||||
|
build() {
|
||||||
|
Pub.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Task()
|
||||||
|
clean() => defaultClean();
|
Loading…
Reference in a new issue