Skip to content

Commit

Permalink
Wire in the media endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
hohonuuli committed Aug 16, 2024
1 parent 048f112 commit 5484967
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ trait MediaEndpointsSuite extends EndpointsSuite with DataInitializer with UserA

given jwtService: JwtService = JwtService("mbari", "foo", "bar")
lazy val fastPhylogenyService = FastPhylogenyService(entityManagerFactory)
lazy val endpoints: MediaEndpoints = MediaEndpoints(entityManagerFactory, fastPhylogenyService, conceptService)
lazy val endpoints: MediaEndpoints = MediaEndpoints(entityManagerFactory, fastPhylogenyService)
private val password = Strings.random(10)

def createMedia(): Seq[Media] = {
Expand Down
17 changes: 3 additions & 14 deletions oni/src/main/scala/org/mbari/oni/Endpoints.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,13 @@
package org.mbari.oni

import jakarta.persistence.EntityManagerFactory
import org.mbari.oni.endpoints.{
AuthorizationEndpoints,
ConceptEndpoints,
ConceptNameEndpoints,
HealthEndpoints,
HistoryEndpoints,
LinkEndpoints,
PhylogenyEndpoints,
PrefNodeEndpoints,
ReferenceEndpoints,
UserAccountEndpoints
}
import org.mbari.oni.endpoints.{AuthorizationEndpoints, ConceptEndpoints, ConceptNameEndpoints, HealthEndpoints, HistoryEndpoints, LinkEndpoints, LinkRealizationEndpoints, LinkTemplateEndpoints, MediaEndpoints, PhylogenyEndpoints, PrefNodeEndpoints, ReferenceEndpoints, UserAccountEndpoints}
import org.mbari.oni.etc.jwt.JwtService
import org.mbari.oni.jdbc.FastPhylogenyService
import sttp.tapir.server.ServerEndpoint
import sttp.tapir.server.metrics.prometheus.PrometheusMetrics
import sttp.shared.Identity
import sttp.tapir.swagger.bundle.SwaggerInterpreter
import org.mbari.oni.endpoints.LinkRealizationEndpoints
import org.mbari.oni.endpoints.LinkTemplateEndpoints

import java.util.concurrent.Executors
import scala.concurrent.{ExecutionContext, Future}
Expand Down Expand Up @@ -56,6 +43,7 @@ object Endpoints:
val linkEndpoints: LinkEndpoints = LinkEndpoints(entityMangerFactory)
val linkRealizationEndpoints: LinkRealizationEndpoints = LinkRealizationEndpoints(entityMangerFactory)
val linkTemplateEndpoints: LinkTemplateEndpoints = LinkTemplateEndpoints(entityMangerFactory)
val mediaEndpoints: MediaEndpoints = MediaEndpoints(entityMangerFactory, phylogenyEndpoints.service)
val prefNodeEndpoints: PrefNodeEndpoints = PrefNodeEndpoints(entityMangerFactory)
val referenceEndpoints: ReferenceEndpoints = ReferenceEndpoints(entityMangerFactory)
val userAccountEndpoints: UserAccountEndpoints = UserAccountEndpoints(entityMangerFactory)
Expand All @@ -69,6 +57,7 @@ object Endpoints:
linkEndpoints,
linkRealizationEndpoints,
linkTemplateEndpoints,
mediaEndpoints,
phylogenyEndpoints,
prefNodeEndpoints,
referenceEndpoints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import scala.concurrent.Future
import org.mbari.oni.etc.jwt.JwtService

class MediaEndpoints(entityManagerFactory: EntityManagerFactory,
fastPhylogenyService: FastPhylogenyService,
conceptService: ConceptService)(using jwtService: JwtService, executionContext: ExecutionContext) extends Endpoints:
fastPhylogenyService: FastPhylogenyService)(using jwtService: JwtService, executionContext: ExecutionContext) extends Endpoints:

private val service = MediaService(entityManagerFactory, fastPhylogenyService)
private val conceptService = ConceptService(entityManagerFactory)
private val base = "media"
private val tag = "Media"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class UserAccountEndpoints(entityManagerFactory: EntityManagerFactory)(using jwt
secureEndpoint
.post
.in(base)
.in(oneOfBody(jsonBody[UserAccountCreate], formBody[UserAccountCreate]))
.in(oneOfBody(jsonBody[UserAccountCreate].description("The user account to create. Accepts camelCase or snake_case."), formBody[UserAccountCreate].description("The user account to create. Accepts camelCase or snake_case.")))
.out(jsonBody[UserAccount])
.name("createUserAccount")
.description("Create a new user account")
Expand Down

0 comments on commit 5484967

Please sign in to comment.