protevus/lib/src/config/config.dart

28 lines
1,018 B
Dart
Raw Normal View History

2016-04-22 02:56:21 +00:00
/// Configuration for this Angel instance.
library angel.config;
import 'dart:io';
2016-12-21 22:05:11 +00:00
import 'package:angel_common/angel_common.dart';
2016-12-24 18:32:47 +00:00
import 'package:angel_multiserver/angel_multiserver.dart';
import 'package:mongo_dart/mongo_dart.dart';
2016-12-10 18:51:02 +00:00
import 'plugins/plugins.dart' as plugins;
2016-04-22 02:56:21 +00:00
2016-06-23 21:54:10 +00:00
/// This is a perfect place to include configuration and load plug-ins.
2016-04-29 01:22:53 +00:00
configureServer(Angel app) async {
2016-12-24 18:32:47 +00:00
var db = new Db(app.mongo_db);
await db.open();
2016-12-24 18:33:04 +00:00
app.container.singleton(db);
2016-12-24 18:32:47 +00:00
// 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')));
2016-06-21 23:39:09 +00:00
await app.configure(loadConfigurationFile());
2016-04-29 01:22:53 +00:00
await app.configure(mustache(new Directory('views')));
2016-12-10 18:51:02 +00:00
await plugins.configureServer(app);
2016-06-23 21:54:10 +00:00
}