1 | import middy from '@middy/core'
|
2 | import { Options as MiddyOptions } from '@middy/util'
|
3 | import { Context as LambdaContext } from 'aws-lambda'
|
4 | import {
|
5 | ServiceDiscoveryClient,
|
6 | ServiceDiscoveryClientConfig,
|
7 | HttpInstanceSummary
|
8 | } from '@aws-sdk/client-servicediscovery'
|
9 |
|
10 | interface Options<AwsServiceDiscoveryClient = ServiceDiscoveryClient>
|
11 | extends Pick<
|
12 | MiddyOptions<
|
13 | AwsServiceDiscoveryClient,
|
14 | ServiceDiscoveryClientConfig
|
15 | >,
|
16 | | 'AwsClient'
|
17 | | 'awsClientOptions'
|
18 | | 'awsClientCapture'
|
19 | | 'fetchData'
|
20 | | 'disablePrefetch'
|
21 | | 'cacheKey'
|
22 | | 'cacheExpiry'
|
23 | | 'setToContext'
|
24 | > {}
|
25 |
|
26 | export type Context<TOptions extends Options | undefined> = TOptions extends {
|
27 | setToContext: true
|
28 | }
|
29 | ? LambdaContext & Record<keyof TOptions['fetchData'], HttpInstanceSummary>
|
30 | : LambdaContext
|
31 |
|
32 | declare function serviceDiscovery<TOptions extends Options | undefined> (
|
33 | options?: TOptions
|
34 | ): middy.MiddlewareObj<unknown, any, Error, Context<TOptions>>
|
35 |
|
36 | export default serviceDiscovery
|
37 |
|
\ | No newline at end of file |