@ -66,73 +66,9 @@ namespace PlexRequests.UI
// by overriding the various methods and properties.
// For more information https://github.com/NancyFx/Nancy/wiki/Bootstrapper
protected override void ConfigureRequestContainer ( TinyIoCContainer container , NancyContext context )
{
// Settings
container . Register < ISettingsService < PlexRequestSettings > , SettingsServiceV2 < PlexRequestSettings > > ( ) ;
container . Register < ISettingsService < CouchPotatoSettings > , SettingsServiceV2 < CouchPotatoSettings > > ( ) ;
container . Register < ISettingsService < AuthenticationSettings > , SettingsServiceV2 < AuthenticationSettings > > ( ) ;
container . Register < ISettingsService < PlexSettings > , SettingsServiceV2 < PlexSettings > > ( ) ;
container . Register < ISettingsService < SonarrSettings > , SettingsServiceV2 < SonarrSettings > > ( ) ;
container . Register < ISettingsService < SickRageSettings > , SettingsServiceV2 < SickRageSettings > > ( ) ;
container . Register < ISettingsService < EmailNotificationSettings > , SettingsServiceV2 < EmailNotificationSettings > > ( ) ;
container . Register < ISettingsService < PushbulletNotificationSettings > , SettingsServiceV2 < PushbulletNotificationSettings > > ( ) ;
container . Register < ISettingsService < PushoverNotificationSettings > , SettingsServiceV2 < PushoverNotificationSettings > > ( ) ;
container . Register < ISettingsService < HeadphonesSettings > , SettingsServiceV2 < HeadphonesSettings > > ( ) ;
container . Register < ISettingsService < LogSettings > , SettingsServiceV2 < LogSettings > > ( ) ;
container . Register < ISettingsService < SlackNotificationSettings > , SettingsServiceV2 < SlackNotificationSettings > > ( ) ;
container . Register < ISettingsService < LandingPageSettings > , SettingsServiceV2 < LandingPageSettings > > ( ) ;
// Repo's
container . Register < IRepository < LogEntity > , GenericRepository < LogEntity > > ( ) ;
container . Register < IRepository < UsersToNotify > , GenericRepository < UsersToNotify > > ( ) ;
container . Register < IRepository < ScheduledJobs > , GenericRepository < ScheduledJobs > > ( ) ;
container . Register < IRepository < IssueBlobs > , GenericRepository < IssueBlobs > > ( ) ;
container . Register < IRequestService , JsonRequestModelRequestService > ( ) ;
container . Register < IIssueService , IssueJsonService > ( ) ;
container . Register < ISettingsRepository , SettingsJsonRepository > ( ) ;
container . Register < IJobRecord , JobRecord > ( ) ;
// Services
container . Register < IAvailabilityChecker , PlexAvailabilityChecker > ( ) ;
container . Register < ICouchPotatoCacher , CouchPotatoCacher > ( ) ;
container . Register < ISonarrCacher , SonarrCacher > ( ) ;
container . Register < ISickRageCacher , SickRageCacher > ( ) ;
container . Register < IJobFactory , CustomJobFactory > ( ) ;
container . Register < IAnalytics , Analytics > ( ) ;
// Api
container . Register < ICouchPotatoApi , CouchPotatoApi > ( ) ;
container . Register < IPushbulletApi , PushbulletApi > ( ) ;
container . Register < IPushoverApi , PushoverApi > ( ) ;
container . Register < ISickRageApi , SickrageApi > ( ) ;
container . Register < ISonarrApi , SonarrApi > ( ) ;
container . Register < IPlexApi , PlexApi > ( ) ;
container . Register < IMusicBrainzApi , MusicBrainzApi > ( ) ;
container . Register < IHeadphonesApi , HeadphonesApi > ( ) ;
container . Register < ISlackApi , SlackApi > ( ) ;
// Notification Service
container . Register < INotificationService , NotificationService > ( ) . AsSingleton ( ) ;
SubscribeAllObservers ( container ) ;
base . ConfigureRequestContainer ( container , context ) ;
var loc = ServiceLocator . Instance ;
loc . SetContainer ( container ) ;
}
protected override void ApplicationStartup ( TinyIoCContainer container , IPipelines pipelines )
{
container . Register < ICacheProvider , MemoryCacheProvider > ( ) . AsSingleton ( ) ;
container . Register < ISqliteConfiguration , DbConfiguration > ( new DbConfiguration ( new SqliteFactory ( ) ) ) ;
container . Register < IRepository < UsersModel > , UserRepository < UsersModel > > ( ) ;
container . Register < IUserMapper , UserMapper > ( ) ;
container . Register < ICustomUserMapper , UserMapper > ( ) ;
ConfigureContainer ( container ) ;
JsonSettings . MaxJsonLength = int . MaxValue ;
@ -144,7 +80,7 @@ namespace PlexRequests.UI
var settings = new SettingsServiceV2 < PlexRequestSettings > ( new SettingsJsonRepository ( new DbConfiguration ( new SqliteFactory ( ) ) , new MemoryCacheProvider ( ) ) ) ;
var baseUrl = settings . GetSettings ( ) . BaseUrl ;
var redirect = string . IsNullOrEmpty ( baseUrl ) ? "~/login" : $"~/{baseUrl}/login" ;
// Enable forms auth
var formsAuthConfiguration = new FormsAuthenticationConfiguration
{
@ -158,13 +94,15 @@ namespace PlexRequests.UI
ServicePointManager . ServerCertificateValidationCallback + =
( sender , certificate , chain , sslPolicyErrors ) = > true ;
SubscribeAllObservers ( container ) ;
}
protected override void ConfigureConventions ( NancyConventions nancyConventions )
{
base . ConfigureConventions ( nancyConventions ) ;
var settings = new SettingsServiceV2 < PlexRequestSettings > ( new SettingsJsonRepository ( new DbConfiguration ( new SqliteFactory ( ) ) , new MemoryCacheProvider ( ) ) ) ;
var settings = new SettingsServiceV2 < PlexRequestSettings > ( new SettingsJsonRepository ( new DbConfiguration ( new SqliteFactory ( ) ) , new MemoryCacheProvider ( ) ) ) ;
var assetLocation = settings . GetSettings ( ) . BaseUrl ;
nancyConventions . StaticContentsConventions . Add (
StaticContentConventionBuilder . AddDirectory ( $"{assetLocation}/Content" , "Content" )
@ -220,5 +158,65 @@ namespace PlexRequests.UI
} ) ;
base . RequestStartup ( container , pipelines , context ) ;
}
private void ConfigureContainer ( TinyIoCContainer container )
{
container . Register < ICacheProvider , MemoryCacheProvider > ( ) . AsSingleton ( ) ;
container . Register < ISqliteConfiguration , DbConfiguration > ( new DbConfiguration ( new SqliteFactory ( ) ) ) ;
container . Register < IRepository < UsersModel > , UserRepository < UsersModel > > ( ) ;
container . Register < IUserMapper , UserMapper > ( ) ;
container . Register < ICustomUserMapper , UserMapper > ( ) ;
container . Register < ISettingsService < EmailNotificationSettings > , SettingsServiceV2 < EmailNotificationSettings > > ( ) ;
container . Register < ISettingsService < PushbulletNotificationSettings > , SettingsServiceV2 < PushbulletNotificationSettings > > ( ) ;
container . Register < ISettingsService < PushoverNotificationSettings > , SettingsServiceV2 < PushoverNotificationSettings > > ( ) ;
container . Register < ISettingsService < SlackNotificationSettings > , SettingsServiceV2 < SlackNotificationSettings > > ( ) ;
// Notification Service
container . Register < INotificationService , NotificationService > ( ) . AsSingleton ( ) ;
// Settings
container . Register < ISettingsService < PlexRequestSettings > , SettingsServiceV2 < PlexRequestSettings > > ( ) ;
container . Register < ISettingsService < CouchPotatoSettings > , SettingsServiceV2 < CouchPotatoSettings > > ( ) ;
container . Register < ISettingsService < AuthenticationSettings > , SettingsServiceV2 < AuthenticationSettings > > ( ) ;
container . Register < ISettingsService < PlexSettings > , SettingsServiceV2 < PlexSettings > > ( ) ;
container . Register < ISettingsService < SonarrSettings > , SettingsServiceV2 < SonarrSettings > > ( ) ;
container . Register < ISettingsService < SickRageSettings > , SettingsServiceV2 < SickRageSettings > > ( ) ;
container . Register < ISettingsService < HeadphonesSettings > , SettingsServiceV2 < HeadphonesSettings > > ( ) ;
container . Register < ISettingsService < LogSettings > , SettingsServiceV2 < LogSettings > > ( ) ;
container . Register < ISettingsService < LandingPageSettings > , SettingsServiceV2 < LandingPageSettings > > ( ) ;
// Repo's
container . Register < IRepository < LogEntity > , GenericRepository < LogEntity > > ( ) ;
container . Register < IRepository < UsersToNotify > , GenericRepository < UsersToNotify > > ( ) ;
container . Register < IRepository < ScheduledJobs > , GenericRepository < ScheduledJobs > > ( ) ;
container . Register < IRepository < IssueBlobs > , GenericRepository < IssueBlobs > > ( ) ;
container . Register < IRequestService , JsonRequestModelRequestService > ( ) ;
container . Register < IIssueService , IssueJsonService > ( ) ;
container . Register < ISettingsRepository , SettingsJsonRepository > ( ) ;
container . Register < IJobRecord , JobRecord > ( ) ;
// Services
container . Register < IAvailabilityChecker , PlexAvailabilityChecker > ( ) ;
container . Register < ICouchPotatoCacher , CouchPotatoCacher > ( ) ;
container . Register < ISonarrCacher , SonarrCacher > ( ) ;
container . Register < ISickRageCacher , SickRageCacher > ( ) ;
container . Register < IJobFactory , CustomJobFactory > ( ) ;
container . Register < IAnalytics , Analytics > ( ) ;
// Api
container . Register < ICouchPotatoApi , CouchPotatoApi > ( ) ;
container . Register < IPushbulletApi , PushbulletApi > ( ) ;
container . Register < IPushoverApi , PushoverApi > ( ) ;
container . Register < ISickRageApi , SickrageApi > ( ) ;
container . Register < ISonarrApi , SonarrApi > ( ) ;
container . Register < IPlexApi , PlexApi > ( ) ;
container . Register < IMusicBrainzApi , MusicBrainzApi > ( ) ;
container . Register < IHeadphonesApi , HeadphonesApi > ( ) ;
container . Register < ISlackApi , SlackApi > ( ) ;
var loc = ServiceLocator . Instance ;
loc . SetContainer ( container ) ;
}
}
}