-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
87 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
myndla-api/src/main/resources/no/ndla/myndlaapi/db/migration/V4__config_tables.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CREATE TABLE configtable ( | ||
configkey TEXT PRIMARY KEY, | ||
value JSONB | ||
); |
53 changes: 53 additions & 0 deletions
53
myndla-api/src/main/scala/no/ndla/myndlaapi/controller/ConfigController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Part of NDLA myndla-api | ||
* Copyright (C) 2023 NDLA | ||
* | ||
* See LICENSE | ||
*/ | ||
|
||
package no.ndla.myndlaapi.controller | ||
|
||
import no.ndla.myndla.model.api.config.ConfigMetaRestricted | ||
import no.ndla.myndla.model.domain.config.ConfigKey | ||
import no.ndla.myndla.service.ConfigService | ||
import no.ndla.myndlaapi.Eff | ||
import no.ndla.network.tapir.NoNullJsonPrinter.jsonBody | ||
import no.ndla.network.tapir.TapirErrors.errorOutputsFor | ||
import no.ndla.network.tapir.{Service, TapirErrorHelpers} | ||
import sttp.tapir.EndpointInput | ||
import sttp.tapir.server.ServerEndpoint | ||
import sttp.tapir._ | ||
import sttp.tapir.generic.auto._ | ||
import sttp.tapir.codec.enumeratum._ | ||
import io.circe.generic.auto._ | ||
|
||
trait ConfigController { | ||
this: ErrorHelpers with TapirErrorHelpers with ConfigService => | ||
class ConfigController extends Service[Eff] { | ||
override protected val prefix: EndpointInput[Unit] = "myndla-api" / "v1" / "config" | ||
|
||
import ErrorHelpers._ | ||
|
||
// val queryConfigKey = query[ConfigKey]("config-key").description(s"The of configuration value. Can only be one of '${ConfigKey.all.mkString("', '")}'") | ||
|
||
val pathConfigKey = | ||
query[ConfigKey]("config-key") | ||
.description(s"The of configuration value. Can only be one of '${ConfigKey.all.mkString("', '")}'") | ||
|
||
import ConfigMetaRestricted.encoder | ||
|
||
def getConfig: ServerEndpoint[Any, Eff] = endpoint.get | ||
.summary("Get db configuration by key") | ||
.description("Get db configuration by key") | ||
.in(pathConfigKey) | ||
.out(jsonBody[ConfigMetaRestricted]) | ||
.errorOut(errorOutputsFor(401, 403, 404)) | ||
.serverLogicPure(configKey => | ||
configService.getConfig(configKey).handleErrorsOrOk) | ||
|
||
override protected val endpoints: List[ServerEndpoint[Any, Eff]] = List( | ||
getConfig | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
myndla/src/main/scala/no/ndla/myndla/model/api/ImportReport.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters