2017-08-08 01:05:11 +02:00
|
|
|
module app;
|
|
|
|
|
|
|
|
import authenticator : Authenticator, MongoDBAuthenticator;
|
|
|
|
import calendarwebapp : CalendarWebapp;
|
|
|
|
import configuration : StringInjector;
|
|
|
|
import event : EventStore, MongoDBEventStore;
|
|
|
|
|
|
|
|
import poodinis;
|
2017-08-07 01:33:17 +02:00
|
|
|
|
|
|
|
import vibe.core.log : logInfo;
|
2017-08-08 01:05:11 +02:00
|
|
|
import vibe.db.mongo.client : MongoClient;
|
|
|
|
import vibe.db.mongo.mongo : connectMongoDB;
|
2017-08-07 01:33:17 +02:00
|
|
|
import vibe.http.fileserver : serveStaticFiles;
|
|
|
|
import vibe.http.router : URLRouter;
|
|
|
|
import vibe.http.server : HTTPServerSettings, listenHTTP, MemorySessionStore;
|
|
|
|
import vibe.web.web : registerWebInterface;
|
2017-08-02 01:56:36 +02:00
|
|
|
|
2017-08-05 17:31:35 +02:00
|
|
|
shared static this()
|
2017-08-02 01:56:36 +02:00
|
|
|
{
|
2017-08-08 01:05:11 +02:00
|
|
|
auto dependencies = new shared DependencyContainer();
|
|
|
|
auto db = connectMongoDB("localhost");
|
|
|
|
dependencies.register!MongoClient.existingInstance(db);
|
|
|
|
dependencies.register!(EventStore, MongoDBEventStore);
|
|
|
|
dependencies.register!(Authenticator, MongoDBAuthenticator);
|
|
|
|
dependencies.register!CalendarWebapp;
|
|
|
|
dependencies.register!(ValueInjector!string, StringInjector);
|
|
|
|
|
2017-08-05 17:31:35 +02:00
|
|
|
auto router = new URLRouter;
|
2017-08-08 01:05:11 +02:00
|
|
|
router.registerWebInterface(dependencies.resolve!CalendarWebapp);
|
2017-08-07 00:01:02 +02:00
|
|
|
router.get("*", serveStaticFiles("public"));
|
2017-08-05 17:31:35 +02:00
|
|
|
|
|
|
|
auto settings = new HTTPServerSettings;
|
|
|
|
settings.port = 8080;
|
|
|
|
settings.bindAddresses = ["::1", "127.0.0.1"];
|
2017-08-06 22:46:42 +02:00
|
|
|
settings.sessionStore = new MemorySessionStore;
|
2017-08-05 17:31:35 +02:00
|
|
|
listenHTTP(settings, router);
|
|
|
|
|
|
|
|
logInfo("Please open http://127.0.0.1:8080/ in your browser.");
|
2017-08-02 01:56:36 +02:00
|
|
|
}
|