예제 #1
0
        public override void Configure(Container container)
        {
            SetConfig(new HostConfig
            {
                UseCamelCase = true,
            });

            Plugins.Add(new RazorFormat());

            //Comment out 2 lines below to change to use local FileSystem instead of S3
            var s3Client = new AmazonS3Client(AwsConfig.AwsAccessKey, AwsConfig.AwsSecretKey, RegionEndpoint.USEast1);

            VirtualFiles = new S3VirtualFiles(s3Client, AwsConfig.S3BucketName);
            AddVirtualFileSources.Add(VirtualFiles);

            container.Register <IPocoDynamo>(c => new PocoDynamo(AwsConfig.CreateAmazonDynamoDb()));
            var db = container.Resolve <IPocoDynamo>();

            db.RegisterTable <Todos.Todo>();
            db.RegisterTable <EmailContacts.Email>();
            db.RegisterTable <EmailContacts.Contact>();
            db.InitSchema();

            //AWS Auth
            container.Register <ICacheClient>(new DynamoDbCacheClient(db, initSchema: true));
            container.Register <IAuthRepository>(new DynamoDbAuthRepository(db, initSchema: true));
            Plugins.Add(CreateAuthFeature());

            //EmailContacts
            ConfigureSqsMqServer(container);
            ConfigureEmailer(container);
            Plugins.Add(new ValidationFeature());
            container.RegisterValidators(typeof(EmailContacts.CreateContact).Assembly);
        }
예제 #2
0
        public AppHost() : base("AWS Examples", typeof(AppHost).Assembly)
        {
#if DEBUG
            LogManager.LogFactory = new StringBuilderLogFactory(); //View logs at /logs
#else
            //Deployed RELEASE build uses Config settings in DynamoDb
            AppSettings = new MultiAppSettings(
                new DynamoDbAppSettings(new PocoDynamo(AwsConfig.CreateAmazonDynamoDb()), initSchema: true),
                new AppSettings());
#endif
        }