forked from floydspace/effect-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApiGatewayV2ClientInstance.ts
More file actions
35 lines (32 loc) · 936 Bytes
/
ApiGatewayV2ClientInstance.ts
File metadata and controls
35 lines (32 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* @since 1.0.0
*/
import { ApiGatewayV2Client } from "@aws-sdk/client-apigatewayv2";
import * as Context from "effect/Context";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as ApiGatewayV2ServiceConfig from "./ApiGatewayV2ServiceConfig.js";
/**
* @since 1.0.0
* @category tags
*/
export class ApiGatewayV2ClientInstance extends Context.Tag(
"@effect-aws/client-api-gateway-v2/ApiGatewayV2ClientInstance",
)<ApiGatewayV2ClientInstance, ApiGatewayV2Client>() {}
/**
* @since 1.0.0
* @category constructors
*/
export const make = Effect.flatMap(
ApiGatewayV2ServiceConfig.toApiGatewayV2ClientConfig,
(config) =>
Effect.acquireRelease(
Effect.sync(() => new ApiGatewayV2Client(config)),
(client) => Effect.sync(() => client.destroy()),
),
);
/**
* @since 1.0.0
* @category layers
*/
export const layer = Layer.scoped(ApiGatewayV2ClientInstance, make);