Created
April 4, 2024 17:23
-
-
Save yanisurbis/56d1959a637cf1564f1085323476e660 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const baseClient = defaultClient.pipe( | |
Http.client.filterStatusOk, | |
Http.client.mapRequest(clientRequest => | |
pipe(clientRequest, Http.request.prependUrl(config.creditSafeApiUrl)), | |
), | |
) | |
const client = pipe( | |
baseClient, | |
Http.client.mapRequestEffect(clientRequest => | |
Effect.gen(function* (_) { | |
if (config.creditSafeDisabled) { | |
const message = 'CreditSafe is disabled' | |
yield* _( | |
new CreditSafeAdapterHttpClientError({ | |
error: new Error(message), | |
message, | |
}), | |
) | |
} | |
return clientRequest | |
}), | |
), | |
Http.client.mapRequestEffect(clientRequest => | |
Effect.gen(function* (_) { | |
// const tokens = yield* _( | |
// Http.request.post('/authenticate'), | |
// Http.request.jsonBody({ | |
// username: config.creditSafeEmail, | |
// password: config.creditSafePassword, | |
// }), | |
// client, | |
// ) | |
return pipe( | |
clientRequest, | |
Http.request.setHeaders({ | |
Authorization: `Bearer SOME_DATA`, | |
}), | |
) | |
}), | |
), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment