From d9e8ce3bbac0f9fdc45975edf95cb785477c6aef Mon Sep 17 00:00:00 2001 From: thosakwe Date: Wed, 21 Sep 2016 00:45:40 -0400 Subject: [PATCH] Bye Furlong --- .gitignore | 103 +++++++---------------- .idea/angel.iml | 21 +++++ .idea/misc.xml | 38 +++++++++ .idea/modules.xml | 8 ++ .idea/runConfigurations/Start_Server.xml | 6 ++ bin/packages | 1 + lib/src/migrations/migrations.dart | 4 - lib/src/migrations/schemas/user.dart | 24 ------ lib/src/migrations/util.dart | 64 -------------- lib/src/models/models.dart | 3 + lib/src/models/user.dart | 36 ++++++++ lib/src/services/users/users.dart | 15 +--- logs/2016-09-20.txt | 3 + pubspec.yaml | 1 - test/packages | 1 + test/services/packages | 1 + tool/grind.dart | 24 +----- tool/packages | 1 + web/packages | 1 + 19 files changed, 151 insertions(+), 204 deletions(-) create mode 100644 .idea/angel.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/runConfigurations/Start_Server.xml create mode 120000 bin/packages delete mode 100644 lib/src/migrations/migrations.dart delete mode 100644 lib/src/migrations/schemas/user.dart delete mode 100644 lib/src/migrations/util.dart create mode 100644 lib/src/models/models.dart create mode 100644 lib/src/models/user.dart create mode 100644 logs/2016-09-20.txt create mode 120000 test/packages create mode 120000 test/services/packages create mode 120000 tool/packages create mode 120000 web/packages diff --git a/.gitignore b/.gitignore index 7c0ac3c..c947f26 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,32 @@ +# Created by .ignore support plugin (hsz.mobi) +### Dart template +# See https://www.dartlang.org/tools/private-files.html + +# Files and directories created by pub +.buildlog +.packages +.project +.pub/ +build/ +**/packages/ + +# Files created by dart2js +# (Most Dart developers will use pub build to compile Dart, use/modify these +# rules if you intend to use dart2js directly +# Convention is to use extension '.dart.js' for Dart compiled to Javascript to +# differentiate from explicit Javascript files) +*.dart.js +*.part.js +*.js.deps +*.js.map +*.info.json + +# Directory created by dartdoc +doc/api/ + +# Don't commit pubspec lock file +# (Library packages only! Remove pattern if developing an application package) +pubspec.lock ### JetBrains template # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 @@ -43,78 +72,4 @@ com_crashlytics_export_strings.xml crashlytics.properties crashlytics-build.properties fabric.properties -### Dart template -# See https://www.dartlang.org/tools/private-files.html -# Files and directories created by pub -.buildlog -.packages -.project -.pub/ -build/ -**/packages/ - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc -doc/api/ - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) -pubspec.lock -# Created by .ignore support plugin (hsz.mobi) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: - -# Sensitive or high-churn files: - -# Gradle: - -# Mongo Explorer plugin: - -## File-based project format: - -## Plugin-specific files: - -# IntelliJ - -# mpeltonen/sbt-idea plugin - -# JIRA plugin - -# Crashlytics plugin (for Android Studio and IntelliJ) -### Dart template -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) - -# Directory created by dartdoc - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) - -packages -**/packages -bin/packages - -.idea - -logs/**/*.txt \ No newline at end of file diff --git a/.idea/angel.iml b/.idea/angel.iml new file mode 100644 index 0000000..1409998 --- /dev/null +++ b/.idea/angel.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..eac82ac --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + General + + + XPath + + + + + AngularJS + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b034384 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Start_Server.xml b/.idea/runConfigurations/Start_Server.xml new file mode 100644 index 0000000..4b1dfdc --- /dev/null +++ b/.idea/runConfigurations/Start_Server.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/bin/packages b/bin/packages new file mode 120000 index 0000000..a16c405 --- /dev/null +++ b/bin/packages @@ -0,0 +1 @@ +../packages \ No newline at end of file diff --git a/lib/src/migrations/migrations.dart b/lib/src/migrations/migrations.dart deleted file mode 100644 index 09ec0b6..0000000 --- a/lib/src/migrations/migrations.dart +++ /dev/null @@ -1,4 +0,0 @@ -library angel.migrations; - -export 'util.dart'; -export 'schemas/user.dart'; \ No newline at end of file diff --git a/lib/src/migrations/schemas/user.dart b/lib/src/migrations/schemas/user.dart deleted file mode 100644 index 96f7ecc..0000000 --- a/lib/src/migrations/schemas/user.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'dart:async'; -import 'package:furlong/furlong.dart'; - -class UsersMigration extends Migration { - @override - String get name => "Users table"; - - @override - Future create(Migrator migrator) async { - migrator.create("users", (table) { - table.id(); - table.string("username"); - table.string("email"); - table.string("password"); - table.dateTime("created_at"); - table.dateTime("updated_at").nullable = true; - }); - } - - @override - Future destroy(Migrator migrator) async { - migrator.drop(["users"]); - } -} \ No newline at end of file diff --git a/lib/src/migrations/util.dart b/lib/src/migrations/util.dart deleted file mode 100644 index 5a0bccd..0000000 --- a/lib/src/migrations/util.dart +++ /dev/null @@ -1,64 +0,0 @@ -import 'dart:async'; -import 'dart:io'; -import 'package:angel_configuration/angel_configuration.dart'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:furlong/furlong.dart'; -import 'package:sqljocky/sqljocky.dart'; - -Future createPool() async { - var app = new Angel(); - await app.configure(loadConfigurationFile()); - Map config = app.properties["db"]["migrate"]; - - if (config == null) - throw new Exception( - "Please provide Furlong configuration with your configuration file."); - - String type = config["type"] ?? "mysql"; - - if (type == "mysql") { - return new ConnectionPool( - host: config["host"] ?? "localhost", - port: config["port"] ?? 3306, - user: config["username"], - password: config["password"], - db: config["database"], - useSSL: config["ssl"] == true); - } else - throw new Exception("Unsupported database driver '$type'."); -} - -migrateDown(List migrations) async { - print("Undoing all migrations..."); - var pool = await createPool(); - var furlong = new Furlong(pool, migrations: migrations); - await furlong.down(); - print("Done."); - exit(0); -} - -migrateReset(List migrations) async { - var pool = await createPool(); - var furlong = new Furlong(pool, migrations: migrations); - await furlong.reset(); - print("Done."); - exit(0); -} - -migrateRevert(List migrations) async { - print("Reverting last batch..."); - var pool = await createPool(); - var furlong = new Furlong(pool, migrations: migrations); - await furlong.revert(); - print("Done."); - exit(0); -} - -migrateUp(List migrations) async { - print("Running all outstanding migrations..."); - var pool = await createPool(); - var furlong = new Furlong(pool, migrations: migrations); - await furlong.up(); - print("Done."); - exit(0); -} \ No newline at end of file diff --git a/lib/src/models/models.dart b/lib/src/models/models.dart new file mode 100644 index 0000000..45dd7d2 --- /dev/null +++ b/lib/src/models/models.dart @@ -0,0 +1,3 @@ +library angel.models; + +export 'user.dart'; \ No newline at end of file diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart new file mode 100644 index 0000000..5c3ce41 --- /dev/null +++ b/lib/src/models/user.dart @@ -0,0 +1,36 @@ +library angel.models.user; + +import 'dart:convert'; +import 'package:angel_mongo/model.dart'; + +class User extends Model { + String email; + String username; + String password; + List roles; + + User( + {String this.email, + String this.username, + String this.password, + List roles}) { + this.roles = roles ?? []; + } + + factory User.fromJson(String json) => new User.fromMap(JSON.decode(json)); + + factory User.fromMap(Map data) => new User( + email: data["email"], + username: data["username"], + password: data["password"], + roles: data["roles"]); + + Map toJson() { + return { + "email": email, + "username": username, + "password": password, + roles: roles + }; + } +} diff --git a/lib/src/services/users/users.dart b/lib/src/services/users/users.dart index d1bed74..bd7532c 100644 --- a/lib/src/services/users/users.dart +++ b/lib/src/services/users/users.dart @@ -3,21 +3,8 @@ import 'package:angel_mongo/angel_mongo.dart'; import 'package:crypto/crypto.dart' show sha256; import 'package:mongo_dart/mongo_dart.dart'; import 'package:validate/validate.dart'; +import '../../models/user.dart'; -class User extends Model { - String email; - String username; - String password; - List roles; - - User( - {String this.email, - String this.username, - String this.password, - List roles}) { - this.roles = roles ?? []; - } -} hashPassword(HookedServiceEvent event) { if (event.data.password != null) { diff --git a/logs/2016-09-20.txt b/logs/2016-09-20.txt new file mode 100644 index 0000000..070aeb0 --- /dev/null +++ b/logs/2016-09-20.txt @@ -0,0 +1,3 @@ +INFO: 2016-09-20 00:52:14.862305: Server listening at http://127.0.0.1:3000 +CONFIG: 2016-09-20 00:52:14.864663: Starting server with given configuration: {mongo_db: mongodb://localhost:27017/angel, db: {web: {database: angel, password: password, username: username}, migrate: {database: angel, password: password, username: root}}, host: 127.0.0.1, port: 3000} +INFO: 2016-09-20 00:52:20.711300: 200 GET / (69 ms) diff --git a/pubspec.yaml b/pubspec.yaml index 7ba9491..d02d6b9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,6 @@ dependencies: angel_mongo: ^1.0.0-dev angel_mustache: ^1.0.0-dev angel_static: ^1.0.0 - furlong: ^1.0.0-dev json_god: ^2.0.0-beta mailer: ^1.1.0+4 validate: ^1.5.2 diff --git a/test/packages b/test/packages new file mode 120000 index 0000000..a16c405 --- /dev/null +++ b/test/packages @@ -0,0 +1 @@ +../packages \ No newline at end of file diff --git a/test/services/packages b/test/services/packages new file mode 120000 index 0000000..4b727bf --- /dev/null +++ b/test/services/packages @@ -0,0 +1 @@ +../../packages \ No newline at end of file diff --git a/tool/grind.dart b/tool/grind.dart index a82b761..1451802 100644 --- a/tool/grind.dart +++ b/tool/grind.dart @@ -1,12 +1,5 @@ -import 'package:angel/src/migrations/migrations.dart'; -import 'package:furlong/furlong.dart'; import 'package:grinder/grinder.dart'; -final List migrations = [ - // Your migrations here! - new UsersMigration() -]; - main(args) => grind(args); @Task() @@ -19,19 +12,4 @@ build() { } @Task() -clean() => defaultClean(); - -@Task("Generates classes from your Furlong migrations.") -generate() async {} - -@Task("Reverts the database state to before any Furlong migrations were run.") -down() => migrateDown(migrations); - -@Task("Undoes and re-runs all Furlong migrations.") -reset() => migrateReset(migrations); - -@Task("Undoes the last batch of Furlong migrations run.") -revert() => migrateRevert(migrations); - -@Task("Runs any outstanding Furlong migrations.") -up() => migrateUp(migrations); +clean() => defaultClean(); \ No newline at end of file diff --git a/tool/packages b/tool/packages new file mode 120000 index 0000000..a16c405 --- /dev/null +++ b/tool/packages @@ -0,0 +1 @@ +../packages \ No newline at end of file diff --git a/web/packages b/web/packages new file mode 120000 index 0000000..a16c405 --- /dev/null +++ b/web/packages @@ -0,0 +1 @@ +../packages \ No newline at end of file