Skip to content

Commit

Permalink
Transactions search API
Browse files Browse the repository at this point in the history
  • Loading branch information
madhead committed Oct 26, 2023
1 parent d9e26d4 commit 5089e8d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions launcher/fly/requests.http
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ Authorization: Bearer {{api_token}}
### Get group currencies
GET https://{{ngrok}}/app/api/group/currencies
Authorization: Bearer {{api_token}}

### Search for transactions
GET https://{{ngrok}}/app/api/group/transactions
Authorization: Bearer {{api_token}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package me.madhead.tyzenhaus.launcher.fly.koin

import me.madhead.tyzenhaus.core.service.GroupCurrenciesService
import me.madhead.tyzenhaus.core.service.GroupMembersService
import me.madhead.tyzenhaus.core.service.TransactionsSearchService
import org.koin.dsl.module

val serviceModule = module {
Expand All @@ -17,4 +18,10 @@ val serviceModule = module {
groupConfigRepository = get(),
)
}

single {
TransactionsSearchService(
transactionRepository = get()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import io.ktor.server.routing.route
import io.ktor.utils.io.core.toByteArray
import me.madhead.tyzenhaus.core.service.GroupCurrenciesService
import me.madhead.tyzenhaus.core.service.GroupMembersService
import me.madhead.tyzenhaus.core.service.TransactionsSearchParams
import me.madhead.tyzenhaus.core.service.TransactionsSearchService
import me.madhead.tyzenhaus.launcher.fly.security.APITokenPrincipal
import org.koin.ktor.ext.get
import org.koin.ktor.ext.inject
Expand All @@ -28,6 +30,7 @@ fun Route.miniAppAPI() {
val config by inject<ApplicationConfig>()
val groupMembersService by inject<GroupMembersService>()
val groupCurrenciesService by inject<GroupCurrenciesService>()
val transactionsSearchService by inject<TransactionsSearchService>()
val webAppDataSecretKeyHash by lazy {
HMAC.hmacSHA256(
"WebAppData".toByteArray(),
Expand Down Expand Up @@ -77,6 +80,12 @@ fun Route.miniAppAPI() {

call.respond(currencies)
}

get("transactions") {
val principal = call.principal<APITokenPrincipal>()!!

call.respond(transactionsSearchService.search(principal.groupId, TransactionsSearchParams()))
}
}
}
}
Expand Down

0 comments on commit 5089e8d

Please sign in to comment.