-
Notifications
You must be signed in to change notification settings - Fork 13
/
ApplicationComponents.scala
58 lines (44 loc) · 2.17 KB
/
ApplicationComponents.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package configuration
import com.madgag.scalagithub.model.User
import com.madgag.scalagithub.{GitHub, GitHubCredentials}
import com.softwaremill.macwire._
import controllers.{Application, _}
import lib.actions.Actions
import lib.sentry.SentryApiClient
import lib.{Bot, CheckpointSnapshoter, Delayer, Droid, PRSnapshot, PRUpdater, RepoSnapshot, RepoUpdater, ScanScheduler}
import play.api.routing.Router
import play.api.{ApplicationLoader, BuiltInComponentsFromContext, Logging}
import router.Routes
import java.nio.file.Path
import scala.concurrent.Await
import scala.concurrent.duration._
class ApplicationComponents(context: ApplicationLoader.Context)
extends BuiltInComponentsFromContext(context) with ReasonableHttpFilters
with AssetsComponents with Logging {
implicit val checkpointSnapshoter: CheckpointSnapshoter = CheckpointSnapshoter
val workingDir: Path = Path.of("/tmp", "bot", "working-dir")
implicit val bot: Bot = Bot.forAccessToken(configuration.get[String]("github.botAccessToken"))
implicit val github: GitHub = bot.github
implicit val authClient: com.madgag.playgithub.auth.Client = com.madgag.playgithub.auth.Client(
id = configuration.get[String]("github.clientId"),
secret = configuration.get[String]("github.clientSecret")
)
val delayer: Delayer = wire[Delayer]
val repoSnapshotFactory: RepoSnapshot.Factory = wire[RepoSnapshot.Factory]
implicit val sentryApiClient: Option[SentryApiClient] = SentryApiClient.instanceOptFrom(configuration)
val repoUpdater: RepoUpdater = wire[RepoUpdater]
val prUpdater: PRUpdater = wire[PRUpdater]
val droid: Droid = wire[Droid]
val scanSchedulerFactory: ScanScheduler.Factory = wire[ScanScheduler.Factory]
val repoAcceptListService: RepoAcceptListService = wire[RepoAcceptListService]
val actions: Actions = wire[Actions]
val controllerAppComponents: ControllerAppComponents = wire[ControllerAppComponents]
val apiController: Api = wire[Api]
val appController: Application = wire[Application]
val authController: Auth = wire[_root_.controllers.Auth]
val router: Router = {
// add the prefix string in local scope for the Routes constructor
val prefix: String = "/"
wire[Routes]
}
}