Created
August 8, 2024 07:30
-
-
Save titouancreach/9688661a0e1fd698ffd21f22e533a8bd 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
import { SQSClient } from '@aws-sdk/client-sqs' | |
import { Config, Context, Effect, Layer } from 'effect' | |
const makeSqsClient = Effect.gen(function* () { | |
const awsAccessKeyId = yield* Config.string('AWS_ACCESS_KEY_ID').pipe( | |
Config.withDescription('AWS Access Key ID'), | |
) | |
const awsSecretAccessKey = yield* Config.string('AWS_SECRET_ACCESS_KEY').pipe( | |
Config.withDescription('AWS Secret'), | |
) | |
const awsRegion = yield* Config.string('AWS_REGION').pipe( | |
Config.withDescription('AWS Region'), | |
Config.withDefault('eu-west-1'), // paris | |
) | |
const client = new SQSClient({ | |
region: awsRegion, | |
credentials: { | |
accessKeyId: awsAccessKeyId, | |
secretAccessKey: awsSecretAccessKey, | |
}, | |
}) | |
return client | |
}) | |
export class SqsClient extends Context.Tag('SqsClient')< | |
SqsClient, | |
Effect.Effect.Success<typeof makeSqsClient> | |
>() { | |
static Live = Layer.effect(this, makeSqsClient) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment