diff --git a/README.md b/README.md index 15b08ac..0586c62 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,13 @@ +# Важно +Сделано за 3 ночи 1 человеком, который был и швец, и жнец, и на дуде игрец. И девопс, и бэкендер и фронтендер. +Спасибо ChatGpt и моей маме. + # Покемон Или BigData Шутливое приложение, которое показывает, насколько огромный зоопарк из названий образовался в дате. Оригинальная идея и отсылки к [этой форме](https://docs.google.com/a/octo.com/forms/d/1kckcq_uv8dk9-W5rIdtqRwCHN4Uh209ELPUjTEZJDxc/viewform) и к [этому](https://github.com/pixelastic/pokemonorbigdata) проекту. + ### How to 1) Build: `./gradlew build` diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index 60daebb..089622a 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -15,6 +15,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-web") implementation("com.fasterxml.jackson.module:jackson-module-kotlin") implementation("org.jetbrains.kotlin:kotlin-reflect") + implementation("org.liquibase:liquibase-core") implementation("com.h2database:h2:2.3.232") implementation("commons-codec:commons-codec:1.17.1") runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.5") diff --git a/backend/src/main/kotlin/ru/posidata/backend/controller/TelegramAuthController.kt b/backend/src/main/kotlin/ru/posidata/backend/controller/TelegramAuthController.kt index f34f573..4d6a6b0 100644 --- a/backend/src/main/kotlin/ru/posidata/backend/controller/TelegramAuthController.kt +++ b/backend/src/main/kotlin/ru/posidata/backend/controller/TelegramAuthController.kt @@ -3,49 +3,13 @@ package ru.posidata.backend.controller import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* -import ru.posidata.backend.service.TelegramAuthService - @RestController @RequestMapping("api") -class TelegramAuthController(private val telegramAuthService: TelegramAuthService) { - // - // - //
- // - // - //Click the button below to log in using your Telegram account:
- // - //: CComponent
() { + /** + * A [CoroutineScope] that should be used by implementing classes. Will be cancelled on unmounting. + */ + val scope: CoroutineScope = CoroutineScope(Dispatchers.Default) + + override fun componentWillUnmount() { + if (scope.isActive) { + scope.cancel() + } + } +} + +abstract class CComponent
: Component
{
+ constructor() : super() {
+ state = jso { init() }
+ }
+ constructor(props: P) : super(props) {
+ state = jso { init(props) }
+ }
+
+ @Suppress(
+ "WRONG_OVERLOADING_FUNCTION_ARGUMENTS",
+ "EMPTY_BLOCK_STRUCTURE_ERROR",
+ "MISSING_KDOC_CLASS_ELEMENTS",
+ "MISSING_KDOC_ON_FUNCTION",
+ )
+ open fun S.init() {}
+
+ /**
+ * @param props
+ */
+ @Suppress(
+ "WRONG_OVERLOADING_FUNCTION_ARGUMENTS",
+ "EMPTY_BLOCK_STRUCTURE_ERROR",
+ "MISSING_KDOC_CLASS_ELEMENTS"
+ )
+ open fun S.init(props: P) {}
+
+ /**
+ * Wrapper for convenient use of `ChildrenBuilder#render()`
+ */
+ override fun render(): ReactNode? = Fragment.create {
+ render()
+ }
+
+ /**
+ * Method that should be overridden in order to render the component
+ */
+ abstract fun ChildrenBuilder.render()
+
+ /**
+ * State setter
+ *
+ * @param stateSetter lambda to set a state
+ */
+ fun setState(stateSetter: S.() -> Unit) {
+ super.setState({ assign(it, stateSetter) })
+ }
+}
+
+private fun WithRequestStatusContext.withModalResponseHandler(
+ response: Response,
+) {
+ if (!response.ok) {
+ setResponse(response)
+ }
+}
+
+val jsonHeaders = Headers()
+ .withAcceptJson()
+ .withContentTypeJson()
+
+fun Headers.withContentTypeJson() = apply {
+ set("Content-Type", "application/json")
+}
+
+fun Headers.withAcceptJson() = apply {
+ set("Accept", "application/json")
+}
+
+suspend fun noopLoadingHandler(request: suspend () -> Response) = request()
+
+suspend fun Response.unpackMessageOrNull(): String? = decodeFieldFromJsonStringOrNull("message")
+
+suspend inline fun Response.decodeFieldFromJsonStringOrNull(fieldName: String): String? = text().await()
+ .let { Json.parseToJsonElement(it) }
+ .let { it as? JsonObject }
+ ?.let { it[fieldName] }
+ ?.let { it as? JsonPrimitive }
+ ?.content
+
+suspend inline fun