github.com/mundipagg/boleto-api@v0.0.0-20230620145841-3f9ec742599f/env/install.go (about) 1 package env 2 3 import ( 4 "os" 5 6 "github.com/PMoneda/flow" 7 "github.com/mundipagg/boleto-api/config" 8 "github.com/mundipagg/boleto-api/metrics" 9 "github.com/mundipagg/boleto-api/models" 10 "github.com/mundipagg/boleto-api/util" 11 ) 12 13 //Config Realiza a configuração da aplicação 14 func Config(devMode, mockMode, disableLog bool) { 15 configFlags(devMode, mockMode, disableLog) 16 registerFlowConnectors() 17 metrics.Install() 18 } 19 20 //ConfigMock Criar configurações de desenvolvimento 21 func ConfigMock(port string) { 22 os.Setenv("AZURE_TENANT_ID", "") 23 os.Setenv("AZURE_CLIENT_ID", "") 24 os.Setenv("AZURE_CLIENT_SECRET", "") 25 os.Setenv("VAULT_NAME", "") 26 os.Setenv("URL_BB_REGISTER_BOLETO", "http://localhost:"+port+"/registrarBoleto") 27 os.Setenv("URL_BB_TOKEN", "http://localhost:"+port+"/oauth/token") 28 os.Setenv("URL_CAIXA", "http://localhost:"+port+"/caixa/registrarBoleto") 29 os.Setenv("URL_CITI", "http://localhost:"+port+"/citi/registrarBoleto") 30 os.Setenv("URL_SANTANDER_TICKET", "tls://localhost:"+port+"/santander/get-ticket") 31 os.Setenv("URL_SANTANDER_REGISTER", "tls://localhost:"+port+"/santander/register") 32 os.Setenv("URL_BRADESCO_SHOPFACIL", "http://localhost:"+port+"/bradescoshopfacil/registrarBoleto") 33 os.Setenv("URL_ITAU_TICKET", "http://localhost:"+port+"/itau/gerarToken") 34 os.Setenv("URL_ITAU_REGISTER", "http://localhost:"+port+"/itau/registrarBoleto") 35 os.Setenv("URL_BRADESCO_NET_EMPRESA", "http://localhost:"+port+"/bradesconetempresa/registrarBoleto") 36 os.Setenv("URL_PEFISA_TOKEN", "http://localhost:"+port+"/pefisa/gerarToken") 37 os.Setenv("URL_PEFISA_REGISTER", "http://localhost:"+port+"/pefisa/registrarBoleto") 38 os.Setenv("URL_STONE_REGISTER", "http://localhost:"+port+"/stone/registrarBoleto") 39 os.Setenv("URL_STONE_TOKEN", "http://localhost:"+port+"/auth/realms/stone_bank/protocol/openid-connect/token") 40 os.Setenv("URL_JPMORGAN", "http://localhost:"+port+"/jpmorgan/registrarBoleto") 41 os.Setenv("STONE_TOKEN_DURATION_IN_MINUTES", "15") 42 os.Setenv("STONE_AUDIENCE", "") 43 os.Setenv("STONE_CLIENT_ID", "") 44 os.Setenv("AZURE_STORAGE_ACCOUNT", "devstoreaccount1") 45 os.Setenv("AZURE_STORAGE_ACCESS_KEY", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==") 46 os.Setenv("AZURE_STORAGE_CONTAINER_NAME", "dev") 47 os.Setenv("AZURE_STORAGE_OPEN_BANK_SK_PATH", "docker/Certificates") 48 os.Setenv("AZURE_STORAGE_OPEN_BANK_SK_NAME", "OpenBank.pem") 49 os.Setenv("AZURE_STORAGE_JP_MORGAN_PK_NAME", "StagingTransportCertificateSecretKey.pem") 50 os.Setenv("AZURE_STORAGE_JP_MORGAN_CRT_NAME", "StagingTransportCertificate.pem") 51 os.Setenv("AZURE_STORAGE_JP_MORGAN_SIGN_NAME", "StagingDigitalSignatureCertificateSecretKey.pem") 52 os.Setenv("AZURE_STORAGE_UPLOAD_PATH", "docker/BoletoOnline/") 53 os.Setenv("AZURE_STORAGE_FALLBACK_FOLDER", "Pending") 54 os.Setenv("MONGODB_URL", "mongodb://localhost:27017") 55 os.Setenv("MONGODB_USER", "test") 56 os.Setenv("MONGODB_PASSWORD", "test") 57 os.Setenv("MONGODB_DATABASE", "STG_Boleto") 58 os.Setenv("MONGODB_BOLETO_COLLECTION", "boletos") 59 os.Setenv("MONGODB_TOKEN_COLLECTION", "tokens") 60 os.Setenv("MONGODB_CREDENTIALS_COLLECTION", "credentials") 61 os.Setenv("MONGODB_AUTH_SOURCE", "admin") 62 os.Setenv("MONGODB_TIMEOUT_CONNECTION", "5") 63 os.Setenv("TOKEN_SAFE_DURATION_IN_MINUTES", "13") 64 os.Setenv("RETRY_NUMBER_GET_BOLETO", "2") 65 os.Setenv("RECOVERYROBOT_EXECUTION_ENABLED", "true") 66 os.Setenv("RECOVERYROBOT_EXECUTION_IN_MINUTES", "1") 67 os.Setenv("SEQ_URL", "http://localhost:5341/api/events/raw") 68 os.Setenv("SEQ_API_KEY", "V0wUDl0wx16YCJhNkQRQ") 69 os.Setenv("TIMEOUT_REGISTER", "30") 70 os.Setenv("TIMEOUT_TOKEN", "20") 71 os.Setenv("TIMEOUT_DEFAULT", "50") 72 os.Setenv("SPLUNK_SOURCE_TYPE", "_json") 73 os.Setenv("SPLUNK_SOURCE_INDEX", "main") 74 os.Setenv("SPLUNK_ENABLED", "true") 75 os.Setenv("SEQ_ENABLED", "true") 76 os.Setenv("SPLUNK_ADDRESS", "http://localhost:8088/services/collector") 77 os.Setenv("SPLUNK_KEY", "bf5e1502-f848-4556-b0fb-c524c880560a") 78 os.Setenv("WAIT_SECONDS_RETENTATION_LOG", "1") 79 os.Setenv("CONN_QUEUE", "amqp://guest:guest@localhost:5672/") 80 os.Setenv("ORIGIN_EXCHANGE", "boletorecovery.main.exchange") 81 os.Setenv("ORIGIN_QUEUE", "boletorecovery.main.queue") 82 os.Setenv("ORIGIN_ROUTING_KEY", "*") 83 os.Setenv("TIME_TO_RECOVERY_WITH_QUEUE_IN_SECONDS", "120") 84 os.Setenv("HEARTBEAT", "30") 85 os.Setenv("QUEUE_MIN_TLS", "1.2") 86 os.Setenv("QUEUE_MAX_TLS", "1.2") 87 os.Setenv("QUEUE_BYPASS_CERTIFICATE", "false") 88 os.Setenv("FORCE_TLS", "false") 89 os.Setenv("NEW_RELIC_APP_NAME", "boleto-api") 90 os.Setenv("NEW_RELIC_LICENCE", "API_KEY") 91 os.Setenv("TELEMETRY_ENABLED", "false") 92 os.Setenv("BUILD_VERSION", "dev") 93 os.Setenv("MASK_LOGS", "true") 94 95 config.Install(true, true, config.Get().DisableLog) 96 registerFlowConnectors() 97 } 98 99 func configFlags(devMode, mockMode, disableLog bool) { 100 if devMode { 101 os.Setenv("INFLUXDB_HOST", "http://localhost") 102 os.Setenv("INFLUXDB_PORT", "8086") 103 os.Setenv("PDF_API", "http://localhost:7070/topdf") 104 os.Setenv("API_PORT", "3000") 105 os.Setenv("API_VERSION", "0.0.1") 106 os.Setenv("ENVIRONMENT", "Development") 107 os.Setenv("SEQ_URL", "http://localhost:5341/api/events/raw") 108 os.Setenv("SEQ_API_KEY", "V0wUDl0wx16YCJhNkQRQ") 109 os.Setenv("ENABLE_REQUEST_LOG", "false") 110 os.Setenv("ENABLE_PRINT_REQUEST", "true") 111 os.Setenv("URL_BB_REGISTER_BOLETO", "https://cobranca.homologa.bb.com.br:7101/registrarBoleto") 112 os.Setenv("URL_BB_TOKEN", "https://oauth.hm.bb.com.br/oauth/token") 113 os.Setenv("CAIXA_ENV", "SGCBS01D") 114 os.Setenv("URL_CAIXA", "https://des.barramento.caixa.gov.br/sibar/ManutencaoCobrancaBancaria/Boleto/Externo") 115 os.Setenv("URL_CITI", "https://citigroupsoauat.citigroup.com/comercioeletronico/registerboleto/RegisterBoletoSOAP") 116 os.Setenv("URL_CITI_BOLETO", "https://ebillpayer.uat.brazil.citigroup.com/ebillpayer/jspInformaDadosConsulta.jsp") 117 os.Setenv("URL_STONE_TOKEN", "https://sandbox-accounts.openbank.stone.com.br/auth/realms/stone_bank/protocol/openid-connect/token") 118 os.Setenv("URL_STONE_REGISTER", "https://sandbox-api.openbank.stone.com.br/api/v1/barcode_payment_invoices") 119 os.Setenv("URL_JPMORGAN", "https://apigatewayqaf.jpmorgan.com/tsapi/v1/boleto") 120 os.Setenv("STONE_TOKEN_DURATION_IN_MINUTES", "15") 121 os.Setenv("STONE_AUDIENCE", "") 122 os.Setenv("STONE_CLIENT_ID", "") 123 os.Setenv("AZURE_STORAGE_ACCOUNT", "devstoreaccount1") 124 os.Setenv("AZURE_STORAGE_ACCESS_KEY", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==") 125 os.Setenv("AZURE_STORAGE_CONTAINER_NAME", "dev") 126 os.Setenv("AZURE_STORAGE_OPEN_BANK_SK_PATH", "docker/Certificates") 127 os.Setenv("AZURE_STORAGE_OPEN_BANK_SK_NAME", "OpenBank.pem") 128 os.Setenv("AZURE_STORAGE_JP_MORGAN_PK_NAME", "StagingTransportCertificateSecretKey.pem") 129 os.Setenv("AZURE_STORAGE_JP_MORGAN_CRT_NAME", "StagingTransportCertificate.pem") 130 os.Setenv("AZURE_STORAGE_JP_MORGAN_SIGN_NAME", "StagingDigitalSignatureCertificateSecretKey.pem") 131 os.Setenv("AZURE_STORAGE_UPLOAD_PATH", "docker/BoletoOnline/") 132 os.Setenv("AZURE_STORAGE_FALLBACK_FOLDER", "Pending") 133 os.Setenv("MONGODB_URL", "mongodb://localhost:27017") 134 os.Setenv("APP_URL", "http://localhost:3000/boleto") 135 os.Setenv("ELASTIC_URL", "http://localhost:9200") 136 os.Setenv("MONGODB_USER", "test") 137 os.Setenv("MONGODB_PASSWORD", "test") 138 os.Setenv("MONGODB_DATABASE", "STG_Boleto") 139 os.Setenv("MONGODB_BOLETO_COLLECTION", "boletos") 140 os.Setenv("MONGODB_TOKEN_COLLECTION", "tokens") 141 os.Setenv("MONGODB_CREDENTIALS_COLLECTION", "credentials") 142 os.Setenv("MONGODB_AUTH_SOURCE", "admin") 143 os.Setenv("MONGODB_TIMEOUT_CONNECTION", "5") 144 os.Setenv("TOKEN_SAFE_DURATION_IN_MINUTES", "13") 145 os.Setenv("RETRY_NUMBER_GET_BOLETO", "2") 146 os.Setenv("PATH_CERTIFICATES", "C:\\cert_boleto_api\\") 147 os.Setenv("CERT_BOLETO_CRT", "C:\\cert_boleto_api\\certificate.crt") 148 os.Setenv("CERT_BOLETO_KEY", "C:\\cert_boleto_api\\pkey.key") 149 os.Setenv("CERT_BOLETO_CA", "C:\\cert_boleto_api\\ca-cert.ca") 150 os.Setenv("CERT_ICP_BOLETO_KEY", "C:\\cert_boleto_api\\ICP_PKey.key") 151 os.Setenv("CERT_ICP_BOLETO_CHAIN_CA", "C:\\cert_boleto_api\\ICP_cadeiaCerts.pem") 152 os.Setenv("URL_SANTANDER_TICKET", "https://ymbdlb.santander.com.br/dl-ticket-services/TicketEndpointService") 153 os.Setenv("URL_SANTANDER_REGISTER", "https://ymbcash.santander.com.br/ymbsrv/CobrancaEndpointService") 154 os.Setenv("URL_BRADESCO_SHOPFACIL", "https://homolog.meiosdepagamentobradesco.com.br/apiboleto/transacao") 155 os.Setenv("ITAU_ENV", "1") 156 os.Setenv("SANTANDER_ENV", "T") 157 os.Setenv("URL_ITAU_REGISTER", "https://gerador-boletos.itau.com.br/router-gateway-app/public/codigo_barras/registro") 158 os.Setenv("URL_ITAU_TICKET", "https://oauth.itau.com.br/identity/connect/token") 159 os.Setenv("URL_BRADESCO_NET_EMPRESA", "https://cobranca.bradesconetempresa.b.br/ibpjregistrotitulows/registrotitulohomologacao") 160 os.Setenv("RECOVERYROBOT_EXECUTION_ENABLED", "true") 161 os.Setenv("RECOVERYROBOT_EXECUTION_IN_MINUTES", "1") 162 os.Setenv("TIMEOUT_REGISTER", "30") 163 os.Setenv("TIMEOUT_TOKEN", "20") 164 os.Setenv("TIMEOUT_DEFAULT", "50") 165 os.Setenv("URL_PEFISA_TOKEN", "https://psdo-hom.pernambucanas.com.br:444/sdcobr/api/oauth/token") 166 os.Setenv("URL_PEFISA_REGISTER", "https://psdo-hom.pernambucanas.com.br:444/sdcobr/api/v2/titulos") 167 os.Setenv("ENABLE_METRICS", "false") 168 os.Setenv("AZURE_TENANT_ID", "") 169 os.Setenv("AZURE_CLIENT_ID", "") 170 os.Setenv("AZURE_CLIENT_SECRET", "") 171 os.Setenv("VAULT_NAME", "") 172 os.Setenv("CERTIFICATE_ICP_NAME", "yourCertificateICP") 173 os.Setenv("PSW_CERTIFICATE_ICP_NAME", "yourPass") 174 os.Setenv("CERTIFICATE_SSL_NAME", "yourCertificateSSL") 175 os.Setenv("PSW_CERTIFICATE_SSL_NAME", "yourPass") 176 os.Setenv("CITIBANK_CERTIFICATE_SSL_NAME", "citibankSSL") 177 os.Setenv("SANTANDER_CERTIFICATE_SSL_NAME", "santanderSSL") 178 os.Setenv("ENABLE_FILESERVER_CERTIFICATE", "false") 179 os.Setenv("SPLUNK_SOURCE_TYPE", "_json") 180 os.Setenv("SPLUNK_SOURCE_INDEX", "main") 181 os.Setenv("SPLUNK_ENABLED", "true") 182 os.Setenv("SEQ_ENABLED", "true") 183 os.Setenv("SPLUNK_ADDRESS", "http://localhost:8088/services/collector") 184 os.Setenv("SPLUNK_KEY", "bf5e1502-f848-4556-b0fb-c524c880560a") 185 os.Setenv("WAIT_SECONDS_RETENTATION_LOG", "1") 186 os.Setenv("CONN_QUEUE", "amqp://guest:guest@localhost:5672/") 187 os.Setenv("ORIGIN_EXCHANGE", "boletorecovery.main.exchange") 188 os.Setenv("ORIGIN_QUEUE", "boletorecovery.main.queue") 189 os.Setenv("ORIGIN_ROUTING_KEY", "*") 190 os.Setenv("TIME_TO_RECOVERY_WITH_QUEUE_IN_SECONDS", "120") 191 os.Setenv("HEARTBEAT", "30") 192 os.Setenv("QUEUE_MIN_TLS", "1.2") 193 os.Setenv("QUEUE_MAX_TLS", "1.2") 194 os.Setenv("QUEUE_BYPASS_CERTIFICATE", "false") 195 os.Setenv("FORCE_TLS", "false") 196 os.Setenv("NEW_RELIC_APP_NAME", "boleto-api") 197 os.Setenv("NEW_RELIC_LICENCE", "API_KEY") 198 os.Setenv("TELEMETRY_ENABLED", "false") 199 os.Setenv("BUILD_VERSION", "dev") 200 os.Setenv("MASK_LOGS", "true") 201 } 202 203 config.Install(mockMode, devMode, disableLog) 204 } 205 206 func registerFlowConnectors() { 207 flow.RegisterConnector("log", util.LogConector) 208 flow.RegisterConnector("apierro", models.BoletoErrorConector) 209 flow.RegisterConnector("tls", util.TlsConector) 210 }