Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hieuwu/supa-spring-kt
Spring Boot backend with RESTful APIs, session management via Supabase
https://github.com/hieuwu/supa-spring-kt
backend restful-api spring-boot supabase supabase-kt swagger-ui
Last synced: 20 days ago
JSON representation
Spring Boot backend with RESTful APIs, session management via Supabase
- Host: GitHub
- URL: https://github.com/hieuwu/supa-spring-kt
- Owner: hieuwu
- License: mit
- Created: 2024-05-22T03:20:05.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-07-13T10:08:21.000Z (4 months ago)
- Last Synced: 2024-10-12T02:29:25.273Z (about 1 month ago)
- Topics: backend, restful-api, spring-boot, supabase, supabase-kt, swagger-ui
- Language: Kotlin
- Homepage:
- Size: 128 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# supa-spring-kt
Spring Boot backend with RESTful APIs, session management via Supabase
## ⭐️ About
This project demonstrate how to integrate Supabase to a RESTful service built with Spring Boot. This backend plays as a middleware to handle requests from multiple clients via RESTful API then interact with Supabase. The common use case is using this service to public APIs to multiple clients so that each client does not have to interact with Supabase via specific SDK.> [!TIP]
> If you want to see the more about Supabase Kotlin Multiplatform samples, check out the [supabase-kt](https://github.com/supabase-community/supabase-kt) repository.## ⚙️ Setup
1. Get started with Spring Boot project with [Spring Initializr](https://start.spring.io/), select Kotlin and Java 17 (JVM)2. Add dependencies to `build.gradle`
```kotlin
val ktor_version = "2.3.10"
implementation("io.ktor:ktor-client-core:$ktor_version")
implementation("io.ktor:ktor-client-java:$ktor_version")
implementation("io.ktor:ktor-client-cio:$ktor_version")val supabaseVersion = "2.4.0"
implementation(platform("io.github.jan-tennert.supabase:bom:$supabaseVersion"))
implementation("io.github.jan-tennert.supabase:gotrue-kt")
implementation("io.github.jan-tennert.supabase:postgrest-kt")
implementation("io.github.jan-tennert.supabase:storage-kt")
implementation("io.github.jan-tennert.supabase:serializer-jackson:$supabaseVersion")
```3. Create `SupabaseConfiguration` class to provide Supabase client instance:
```kotlin
@Configuration
class SupabaseConfiguration {
@Bean
fun supabaseClient(): SupabaseClient {
return createSupabaseClient(
supabaseUrl = "SUPABASE_URL",
supabaseKey = "SUPABASE_KEY"
) {
install(Auth)
install(Postgrest)
defaultSerializer = JacksonSerializer()
}
}
}
```
4. Use Supabase Client
```kotlin
@Repository
class ProductRepository(supabase: SupabaseClient) {
...
}
```## 📒 API docs & Supabase schema
### API Docs### Schema
## 👨💻 Run
`./gradlew run`**Service status:** `http://localhost:8080/actuator/health`
**Swagger API:** `http://localhost:8080/swagger-ui/index.html`
### With Docker
1. Run below command to build the image
```bash
./gradlew build && java -jar build/libs/gs-spring-boot-docker-0.1.0.jar
``````bash
docker build --build-arg JAR_FILE=build/libs/\*.jar -t springio/gs-spring-boot-docker .
```
2. Run the image
```bash
docker-compose up
```