diff --git a/lib/src/config/config.dart b/lib/src/config/config.dart index 3e2454a7..dfb658ec 100644 --- a/lib/src/config/config.dart +++ b/lib/src/config/config.dart @@ -3,10 +3,23 @@ library angel.config; import 'dart:io'; import 'package:angel_common/angel_common.dart'; +import 'package:angel_multiserver/angel_multiserver.dart'; +import 'package:mongo_dart/mongo_dart.dart'; import 'plugins/plugins.dart' as plugins; /// This is a perfect place to include configuration and load plug-ins. configureServer(Angel app) async { + var db = new Db(app.mongo_db); + await db.open(); + + // Uncomment this to enable session synchronization across instances. + // This will add the overhead of querying a database at the beginning + // and end of every request. Thus, it should only be activated if necessary. + // + // For applications of scale, it is better to steer clear of session use + // entirely. + // await app.configure(new MongoSessionSynchronizer(db.collection('sessions'))); + await app.configure(loadConfigurationFile()); await app.configure(mustache(new Directory('views'))); await plugins.configureServer(app); diff --git a/lib/src/services/services.dart b/lib/src/services/services.dart index 3deae452..e3b08ae3 100644 --- a/lib/src/services/services.dart +++ b/lib/src/services/services.dart @@ -7,7 +7,7 @@ import 'package:mongo_dart/mongo_dart.dart'; import 'user.dart' as User; configureServer(Angel app) async { - Db db = new Db(app.mongo_db); + Db db = app.container.make(Db); await db.open(); await app.configure(User.configureServer(db));