libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

Main.kt (3113B)


      1 /*
      2  * This file is part of LibEuFin.
      3  * Copyright (C) 2023-2025, 2026 Taler Systems S.A.
      4 
      5  * LibEuFin is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU Affero General Public License as
      7  * published by the Free Software Foundation; either version 3, or
      8  * (at your option) any later version.
      9 
     10  * LibEuFin is distributed in the hope that it will be useful, but
     11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General
     13  * Public License for more details.
     14 
     15  * You should have received a copy of the GNU Affero General Public
     16  * License along with LibEuFin; see the file COPYING.  If not, see
     17  * <http://www.gnu.org/licenses/>
     18  */
     19 
     20 /**
     21  * This file collects all the CLI subcommands and runs
     22  * them.  The actual implementation of each subcommand is
     23  * kept in their respective files.
     24  */
     25 package tech.libeufin.nexus
     26 
     27 import io.ktor.server.application.*
     28 import org.slf4j.Logger
     29 import org.slf4j.LoggerFactory
     30 import kotlinx.serialization.Serializable
     31 import kotlinx.serialization.Contextual
     32 import tech.libeufin.common.api.OpenApiInfo
     33 import tech.libeufin.common.api.talerApi
     34 import tech.libeufin.common.setupSecurityProperties
     35 import tech.libeufin.common.VERSION
     36 import tech.libeufin.nexus.api.revenueApi
     37 import tech.libeufin.nexus.api.preparedTransferAPI
     38 import tech.libeufin.nexus.api.wireGatewayApi
     39 import tech.libeufin.nexus.api.observabilityApi
     40 import tech.libeufin.nexus.cli.LibeufinNexus
     41 import tech.libeufin.nexus.db.Database
     42 import com.github.ajalt.clikt.core.main
     43 import tech.libeufin.common.IBAN
     44 import java.time.Instant
     45 
     46 /** Triple identifying one IBAN bank account */
     47 data class IbanAccountMetadata(
     48     val iban: IBAN,
     49     val bic: String?,
     50     val name: String
     51 )
     52 
     53 fun Application.nexusApi(db: Database, cfg: NexusConfig, serveSpec: Boolean = false) = talerApi(
     54     LoggerFactory.getLogger("libeufin-nexus-api"),
     55     OpenApiInfo(
     56         title = "LibEuFin Nexus API",
     57         version = VERSION,
     58         description = "Taler wire gateway, wire transfer gateway, revenue, and observability APIs for LibEuFin Nexus",
     59         securityConfig = { 
     60         securityScheme("bearerAuth") {
     61             type = io.github.smiley4.ktoropenapi.config.AuthType.HTTP
     62             scheme = io.github.smiley4.ktoropenapi.config.AuthScheme.BEARER
     63             bearerFormat = "token"
     64         }
     65         securityScheme("basicAuth") {
     66             type = io.github.smiley4.ktoropenapi.config.AuthType.HTTP
     67             scheme = io.github.smiley4.ktoropenapi.config.AuthScheme.BASIC
     68             description = "HTTP Basic authentication, supported only on compatibility-enabled endpoints"
     69         }
     70     }
     71     ),
     72     serveSpec = serveSpec
     73 ) {
     74     wireGatewayApi(db, cfg)
     75     preparedTransferAPI(db, cfg)
     76     revenueApi(db, cfg)
     77     observabilityApi(db, cfg)
     78 }
     79 
     80 fun main(args: Array<String>) {
     81     setupSecurityProperties()
     82     LibeufinNexus().main(args)
     83 }
     84 
     85 @Serializable
     86 data class TaskStatus(
     87     @Contextual
     88     val last_successfull: Instant? = null,
     89     @Contextual
     90     val last_trial: Instant? = null
     91 )