@Override public void run(BithubServerConfiguration config, Environment environment) throws Exception { String githubUser = config.getGithubConfiguration().getUser(); String githubToken = config.getGithubConfiguration().getToken(); String githubWebhookUser = config.getGithubConfiguration().getWebhookConfiguration().getUsername(); String githubWebhookPwd = config.getGithubConfiguration().getWebhookConfiguration().getPassword(); List<RepositoryConfiguration> githubRepositories = config.getGithubConfiguration().getRepositories(); BigDecimal payoutRate = config.getBithubConfiguration().getPayoutRate(); String organizationName = config.getOrganizationConfiguration().getName(); String donationUrl = config.getOrganizationConfiguration().getDonationUrl().toExternalForm(); String coinbaseApiKey = config.getCoinbaseConfiguration().getApiKey(); String coinbaseApiSecret = config.getCoinbaseConfiguration().getApiSecret(); GithubClient githubClient = new GithubClient(githubUser, githubToken); CoinbaseClient coinbaseClient = new CoinbaseClient(coinbaseApiKey, coinbaseApiSecret); CacheManager cacheManager = new CacheManager(coinbaseClient, githubClient, githubRepositories, payoutRate); environment.servlets().addFilter("CORS", CrossOriginFilter.class) .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); environment.lifecycle().manage(cacheManager); environment.jersey().register(new GithubController(githubRepositories, githubClient, coinbaseClient, payoutRate)); environment.jersey().register(new StatusController(cacheManager, githubRepositories)); environment.jersey().register(new DashboardController(organizationName, donationUrl, cacheManager)); environment.jersey().register(new IOExceptionMapper()); environment.jersey().register(new UnauthorizedHookExceptionMapper()); environment.jersey().register(new BasicAuthProvider<>(new GithubWebhookAuthenticator(githubWebhookUser, githubWebhookPwd), GithubWebhookAuthenticator.REALM)); }